patch_manager: use rename to back up old patch file

This commit is contained in:
Megamouse 2020-09-10 01:16:30 +02:00
parent 44371dedd9
commit 8d56dd1969

View file

@ -942,10 +942,10 @@ bool patch_manager_dialog::handle_json(const QByteArray& data)
// Back up current patch file if possible // Back up current patch file if possible
if (fs::is_file(path)) if (fs::is_file(path))
{ {
if (const std::string path_old = path + ".old"; if (const std::string back_up_path = path + ".old";
!fs::copy_file(path, path_old, true)) !fs::rename(path, back_up_path, true))
{ {
patch_log.error("Could not back up current patches to %s (%s)", path_old, fs::g_tls_error); patch_log.error("Could not back up current patches to %s (%s)", back_up_path, fs::g_tls_error);
return false; return false;
} }
} }