cellSaveData: try to handle occasional failures

Retry moving directory on FILE_ACCESS_ERROR
This commit is contained in:
Nekotekina 2019-01-31 01:07:07 +03:00
parent 25aa5f80a6
commit 400718dfd9

View file

@ -927,15 +927,19 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
fs::remove_all(old_path, false);
// Backup old savedata
if (!fs::rename(dir_path, old_path, true))
while (!fs::rename(dir_path, old_path, true))
{
fmt::throw_exception("Failed to move directory %s", dir_path);
// Try to ignore access error in order to prevent spurious failure
if (Emu.IsStopped() || fs::g_tls_error != fs::error::acces)
fmt::throw_exception("Failed to move directory %s (%s)", dir_path, fs::g_tls_error);
}
// Commit new savedata
if (!fs::rename(new_path, dir_path, false))
while (!fs::rename(new_path, dir_path, false))
{
fmt::throw_exception("Failed to move directory %s", new_path);
// TODO: handle the case when only commit failed at the next save load
if (Emu.IsStopped() || fs::g_tls_error != fs::error::acces)
fmt::throw_exception("Failed to move directory %s (%s)", new_path, fs::g_tls_error);
}
// Remove backup again (TODO: may be changed to persistent backup implementation)