Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #8750 from leoetlino/close-before-rename
IOS/FS: Fix FST write failure on some platforms
  • Loading branch information
JMC47 committed Apr 18, 2020
2 parents 21e3e14 + b2cf106 commit 2d8758d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Source/Core/Core/IOS/FS/HostBackend/FS.cpp
Expand Up @@ -177,9 +177,17 @@ void HostFileSystem::SaveFst()

const std::string dest_path = GetFstFilePath();
const std::string temp_path = File::GetTempFilenameForAtomicWrite(dest_path);
File::IOFile file{temp_path, "wb"};
if (!file.WriteArray(to_write.data(), to_write.size()) || !File::Rename(temp_path, dest_path))
ERROR_LOG(IOS_FS, "Failed to write new FST");
{
// This temporary file must be closed before it can be renamed.
File::IOFile file{temp_path, "wb"};
if (!file.WriteArray(to_write.data(), to_write.size()))
{
PanicAlert("IOS_FS: Failed to write new FST");
return;
}
}
if (!File::Rename(temp_path, dest_path))
PanicAlert("IOS_FS: Failed to rename temporary FST file");
}

HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string& path)
Expand Down

0 comments on commit 2d8758d

Please sign in to comment.