From 21a8d170d71b4ccccc6068638024c31fa36cd0e3 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Fri, 12 Jun 2026 14:13:39 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaUpdater/main.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/MaaUpdater/main.cpp b/src/MaaUpdater/main.cpp index d589fa564a..202603b4f2 100644 --- a/src/MaaUpdater/main.cpp +++ b/src/MaaUpdater/main.cpp @@ -102,7 +102,7 @@ static bool RetryFileOp(const std::function& op, int maxAttempts = 5, DW static std::wstring RenameLockedFile(const std::wstring& path); static bool ForceDeleteFile(const std::wstring& path); static bool ForceRemoveDirectoryRecursive(const std::wstring& dir); -static bool InstallFileAtomic(const std::wstring& sourcePath, const std::wstring& targetPath, const std::wstring& backupDirForFailedAtomic); +static bool InstallFileAtomic(const std::wstring& sourcePath, const std::wstring& targetPath); static void CleanupPendingDeleteFiles(const std::wstring& rootDir); struct UpdateProgressUi @@ -1651,8 +1651,7 @@ static bool ForceRemoveDirectoryRecursive(const std::wstring& dir) // a separate copy-then-delete cycle. // If ReplaceFileW fails, falls back to copy-then-move with retry. static bool InstallFileAtomic(const std::wstring& sourcePath, - const std::wstring& targetPath, - const std::wstring& backupDirForFailedAtomic) + const std::wstring& targetPath) { EnsureParentDirectory(targetPath); @@ -1682,9 +1681,6 @@ static bool InstallFileAtomic(const std::wstring& sourcePath, } // --- Try ReplaceFileW (atomic swap) --- - // backupDirForFailedAtomic is unused by ReplaceFileW itself; we pass nullptr - // because we already have a proper backup in the backupDir. ReplaceFileW's - // backup is only used as a last-resort safety net. { auto replaceOp = [&]() -> bool { // ReplaceFileW(replaced, replacement, backup, flags, exclude, reserved) @@ -1998,7 +1994,7 @@ int wmain(int argc, wchar_t* argv[]) if (isSourceFile) { // Use atomic file replacement for individual files - installOk = InstallFileAtomic(sourcePath, targetPath, backupDir); + installOk = InstallFileAtomic(sourcePath, targetPath); } else { // Directories: use the original move logic auto moveOp = [&]() -> bool {