From 194fc63232c18f6232d9fba756aa8820b76d3b25 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 25 Apr 2020 15:23:36 +1000 Subject: [PATCH] GameList: Flush game list after re-scanning Should hopefully fix random gamelist corruption. --- src/core/game_list.cpp | 10 ++++++++++ src/core/game_list.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/core/game_list.cpp b/src/core/game_list.cpp index 76ea8e7a8..d8aadd1a1 100644 --- a/src/core/game_list.cpp +++ b/src/core/game_list.cpp @@ -497,6 +497,14 @@ bool GameList::WriteEntryToCache(const GameListEntry* entry, ByteStream* stream) return result; } +void GameList::FlushCacheFileStream() +{ + if (!m_cache_write_stream) + return; + + m_cache_write_stream->Flush(); +} + void GameList::CloseCacheFileStream() { if (!m_cache_write_stream) @@ -588,6 +596,8 @@ void GameList::ScanDirectory(const char* path, bool recursive, ProgressCallback* entry = {}; } + FlushCacheFileStream(); + progress->SetProgressValue(static_cast(files.size())); progress->PopState(); } diff --git a/src/core/game_list.h b/src/core/game_list.h index 1ea03a5cc..c85915200 100644 --- a/src/core/game_list.h +++ b/src/core/game_list.h @@ -107,6 +107,7 @@ private: bool LoadEntriesFromCache(ByteStream* stream); bool OpenCacheForWriting(); bool WriteEntryToCache(const GameListEntry* entry, ByteStream* stream); + void FlushCacheFileStream(); void CloseCacheFileStream(); void DeleteCacheFile();