Merge pull request #11197 from shuffle2/updater

WinUpdater: fix renaming of Updater
This commit is contained in:
JosJuice 2022-10-23 10:44:24 +02:00 committed by GitHub
commit 100121c0b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 11 deletions

View File

@ -464,16 +464,10 @@ bool UpdateFiles(const std::vector<TodoList::UpdateOp>& to_update,
// after entire update has completed, and have it delete our relocated executable. For now we // after entire update has completed, and have it delete our relocated executable. For now we
// just let the relocated file hang around. // just let the relocated file hang around.
// It is enough to match based on filename, don't need File/VolumeId etc. // It is enough to match based on filename, don't need File/VolumeId etc.
if (op.filename == self_filename) const bool is_self = op.filename == self_filename;
{ #else
auto reloc_path = self_path; // On other platforms, the renaming is handled by Dolphin before running the Updater.
reloc_path.replace_filename("Updater.2.exe"); const bool is_self = false;
if (!MoveFile(self_path.wstring().c_str(), reloc_path.wstring().c_str()))
{
fprintf(log_fp, "Failed to move %s.\n", op.filename.c_str());
// Just let the Copy fail, later.
}
}
#endif #endif
std::string contents; std::string contents;
@ -488,7 +482,7 @@ bool UpdateFiles(const std::vector<TodoList::UpdateOp>& to_update,
fprintf(log_fp, "File %s was already up to date. Partial update?\n", op.filename.c_str()); fprintf(log_fp, "File %s was already up to date. Partial update?\n", op.filename.c_str());
continue; continue;
} }
else if (!op.old_hash || contents_hash != *op.old_hash) else if (!op.old_hash || contents_hash != *op.old_hash || is_self)
{ {
if (!BackupFile(path)) if (!BackupFile(path))
return false; return false;