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.
This commit is contained in:
Richard Stanway
2023-07-21 03:02:31 +02:00
parent 890a7fddd8
commit b7fddceb67
+5 -2
View File
@@ -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) {