From 34e5a39e004a8a3eec43741c2cf345218ae32ffa Mon Sep 17 00:00:00 2001 From: Blue Date: Tue, 10 Jun 2025 15:00:45 -0700 Subject: [PATCH] Set MOVEFILE_WRITE_THROUGH when moving distribution VHD's --- src/windows/service/exe/LxssUserSession.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/windows/service/exe/LxssUserSession.cpp b/src/windows/service/exe/LxssUserSession.cpp index 3ced3bef..468273f4 100644 --- a/src/windows/service/exe/LxssUserSession.cpp +++ b/src/windows/service/exe/LxssUserSession.cpp @@ -940,10 +940,11 @@ HRESULT LxssUserSessionImpl::MoveDistribution(_In_ LPCGUID DistroGuid, _In_ LPCW } // Move the VHD to the new location. - THROW_IF_WIN32_BOOL_FALSE(MoveFileEx(distro.VhdFilePath.c_str(), newVhdPath.c_str(), MOVEFILE_COPY_ALLOWED)); + THROW_IF_WIN32_BOOL_FALSE(MoveFileEx(distro.VhdFilePath.c_str(), newVhdPath.c_str(), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH)); auto revert = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [&]() { - THROW_IF_WIN32_BOOL_FALSE(MoveFileEx(newVhdPath.c_str(), distro.VhdFilePath.c_str(), MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)); + THROW_IF_WIN32_BOOL_FALSE(MoveFileEx( + newVhdPath.c_str(), distro.VhdFilePath.c_str(), MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH)); // Write the location back to the original path in case the second registry write failed. Otherwise this is a no-op. registration.Write(Property::BasePath, distro.BasePath.c_str());