From e87a97eb8c728475dd7915c698b615215f5d2051 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 31 Aug 2022 20:19:05 -0700 Subject: [PATCH] UI/updater: Fix silent failure on auto-update --- UI/win-update/updater/updater.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/UI/win-update/updater/updater.cpp b/UI/win-update/updater/updater.cpp index 9e7e978c5..129b3eee0 100644 --- a/UI/win-update/updater/updater.cpp +++ b/UI/win-update/updater/updater.cpp @@ -798,9 +798,12 @@ static void AddPackageRemovedFiles(const Json &package) /* Technically GetFileAttributes can fail for other reasons, * so double-check by also checking the last error */ if (GetFileAttributesW(removedFileName) == - INVALID_FILE_ATTRIBUTES && - GetLastError() == ERROR_FILE_NOT_FOUND) - continue; + INVALID_FILE_ATTRIBUTES) { + int err = GetLastError(); + if (err == ERROR_FILE_NOT_FOUND || + err == ERROR_PATH_NOT_FOUND) + continue; + } deletion_t deletion; deletion.originalFilename = removedFileName; @@ -1577,9 +1580,13 @@ static bool Update(wchar_t *cmdLine) } } - for (deletion_t &deletion : deletions) - if (!RenameRemovedFile(deletion)) + for (deletion_t &deletion : deletions) { + if (!RenameRemovedFile(deletion)) { + Status(L"Update failed: Couldn't remove " + L"obsolete files"); return false; + } + } /* ------------------------------------- * * Install virtual camera */