Set MOVEFILE_WRITE_THROUGH when moving distribution VHD's

This commit is contained in:
Blue 2025-06-10 15:00:45 -07:00
parent 456b68125f
commit 34e5a39e00

View File

@ -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());