From d0edd44a6994454a8b03e48bc79941af8b55f5d7 Mon Sep 17 00:00:00 2001 From: Eladash Date: Tue, 2 Mar 2021 17:13:15 +0200 Subject: [PATCH] Atomic trophy status updates --- rpcs3/Loader/TROPUSR.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/rpcs3/Loader/TROPUSR.cpp b/rpcs3/Loader/TROPUSR.cpp index 298af4db06..1eb0c7955a 100644 --- a/rpcs3/Loader/TROPUSR.cpp +++ b/rpcs3/Loader/TROPUSR.cpp @@ -107,30 +107,31 @@ bool TROPUSRLoader::LoadTables() // TODO: TROPUSRLoader::Save deletes the TROPUSR and creates it again. This is probably very slow. bool TROPUSRLoader::Save(const std::string& filepath) { - if (!m_file.open(vfs::get(filepath), fs::rewrite)) + fs::pending_file temp(vfs::get(filepath)); + + if (!temp.file) { return false; } - m_file.write(m_header); + temp.file.write(m_header); for (const TROPUSRTableHeader& tableHeader : m_tableHeaders) { - m_file.write(tableHeader); + temp.file.write(tableHeader); } for (const auto& entry : m_table4) { - m_file.write(entry); + temp.file.write(entry); } for (const auto& entry : m_table6) { - m_file.write(entry); + temp.file.write(entry); } - m_file.release(); - return true; + return temp.commit(); } bool TROPUSRLoader::Generate(const std::string& filepath, const std::string& configpath)