mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Fix atomicity of savedata/trophy data writes
This commit is contained in:
parent
932f31e37b
commit
d4af8dd89a
@ -748,7 +748,7 @@ namespace fs
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
template <bool Flush = false, typename... Args>
|
||||
bool write_file(const std::string& path, bs_t<fs::open_mode> mode, const Args&... args)
|
||||
{
|
||||
// Always use write flag, remove read flag
|
||||
@ -758,14 +758,19 @@ namespace fs
|
||||
{
|
||||
// Specialization for [const void*, usz] args
|
||||
f.write(args...);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write args sequentially
|
||||
(f.write(args), ...);
|
||||
return true;
|
||||
}
|
||||
|
||||
if constexpr (Flush)
|
||||
{
|
||||
f.sync();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1911,7 +1911,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
|
||||
if (auto file = pair.second.release())
|
||||
{
|
||||
auto fvec = static_cast<fs::container_stream<std::vector<uchar>>&>(*file);
|
||||
fs::file(new_path + vfs::escape(pair.first), fs::rewrite).write(fvec.obj);
|
||||
ensure(fs::write_file<true>(new_path + vfs::escape(pair.first), fs::rewrite, fvec.obj));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ bool TRPLoader::Install(const std::string& dest, bool show)
|
||||
}
|
||||
|
||||
// Create the file in the temporary directory
|
||||
success = fs::write_file(temp + '/' + vfs::escape(entry.name), fs::create + fs::excl, buffer);
|
||||
success = fs::write_file<true>(temp + '/' + vfs::escape(entry.name), fs::create + fs::excl, buffer);
|
||||
if (!success)
|
||||
{
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user