GameList: Fix cache corruption after scanning for new games

This commit is contained in:
Connor McLaughlin 2020-09-10 00:23:24 +10:00
parent 24716591a9
commit 5b17ad11a7
1 changed files with 4 additions and 3 deletions

View File

@ -367,8 +367,11 @@ bool GameList::OpenCacheForWriting()
m_cache_write_stream = m_cache_write_stream =
FileSystem::OpenFile(m_cache_filename.c_str(), BYTESTREAM_OPEN_CREATE | BYTESTREAM_OPEN_WRITE | FileSystem::OpenFile(m_cache_filename.c_str(), BYTESTREAM_OPEN_CREATE | BYTESTREAM_OPEN_WRITE |
BYTESTREAM_OPEN_APPEND | BYTESTREAM_OPEN_STREAMED); BYTESTREAM_OPEN_APPEND | BYTESTREAM_OPEN_STREAMED);
if (!m_cache_write_stream) if (!m_cache_write_stream || !m_cache_write_stream->SeekToEnd())
{
m_cache_write_stream.reset();
return false; return false;
}
if (m_cache_write_stream->GetPosition() == 0) if (m_cache_write_stream->GetPosition() == 0)
{ {
@ -516,8 +519,6 @@ void GameList::ScanDirectory(const char* path, bool recursive, ProgressCallback*
entry = {}; entry = {};
} }
FlushCacheFileStream();
progress->SetProgressValue(static_cast<u32>(files.size())); progress->SetProgressValue(static_cast<u32>(files.size()));
progress->PopState(); progress->PopState();
} }