@samitouri / QOSAMI-WSL / commits / 3164dc42

Set MOVEFILE_WRITE_THROUGH when moving distribution VHD's (#13087)

Blue committed Jun 11, 2025 at 11:31 UTC 3164dc425a2ed564545c69e90e05a0a2db9533a4
1 file changed +3 -2
src/windows/service/exe/LxssUserSession.cpp
+3 -2
@@ -940,10 +940,11 @@ HRESULT LxssUserSessionImpl::MoveDistribution(_In_ LPCGUID DistroGuid, _In_ LPCW
940 }
941
942 // Move the VHD to the new location.
943 - THROW_IF_WIN32_BOOL_FALSE(MoveFileEx(distro.VhdFilePath.c_str(), newVhdPath.c_str(), MOVEFILE_COPY_ALLOWED));
943 + THROW_IF_WIN32_BOOL_FALSE(MoveFileEx(distro.VhdFilePath.c_str(), newVhdPath.c_str(), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH));
944
945 auto revert = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [&]() {
946 - THROW_IF_WIN32_BOOL_FALSE(MoveFileEx(newVhdPath.c_str(), distro.VhdFilePath.c_str(), MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING));
946 + THROW_IF_WIN32_BOOL_FALSE(MoveFileEx(
947 + newVhdPath.c_str(), distro.VhdFilePath.c_str(), MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH));
948
949 // Write the location back to the original path in case the second registry write failed. Otherwise this is a no-op.
950 registration.Write(Property::BasePath, distro.BasePath.c_str());