From b7fddceb67926e26f2b6f2124b36815e54cf5c74 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Fri, 21 Jul 2023 02:59:34 +0200 Subject: [PATCH] updater: Treat mapped file errors as a sharing violation For whatever reason there exists a different error code if the file has been opened as a mapped file, so we need to handle it. --- UI/win-update/updater/updater.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/UI/win-update/updater/updater.cpp b/UI/win-update/updater/updater.cpp index 0c470b64b..5e353ce24 100644 --- a/UI/win-update/updater/updater.cpp +++ b/UI/win-update/updater/updater.cpp @@ -1068,8 +1068,10 @@ static bool UpdateFile(ZSTD_DCtx *ctx, update_t &file) L".old"); if (!MyCopyFile(file.outputPath.c_str(), oldFileRenamedPath)) { + DWORD err = GetLastError(); int is_sharing_violation = - (GetLastError() == ERROR_SHARING_VIOLATION); + (err == ERROR_SHARING_VIOLATION || + err == ERROR_USER_MAPPED_FILE); if (is_sharing_violation) Status(L"Update failed: %s is still in use. " @@ -1128,7 +1130,8 @@ static bool UpdateFile(ZSTD_DCtx *ctx, update_t &file) if (!installed_ok) { int is_sharing_violation = - (error_code == ERROR_SHARING_VIOLATION); + (error_code == ERROR_SHARING_VIOLATION || + error_code == ERROR_USER_MAPPED_FILE); if (is_sharing_violation) { if (!already_tried_to_move) {