summaryrefslogtreecommitdiff
path: root/Source/Core/UICommon/GameFileCache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/UICommon/GameFileCache.cpp')
-rw-r--r--Source/Core/UICommon/GameFileCache.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp
index c551016d7f..71c73a5f9f 100644
--- a/Source/Core/UICommon/GameFileCache.cpp
+++ b/Source/Core/UICommon/GameFileCache.cpp
@@ -90,7 +90,8 @@ std::shared_ptr<const GameFile> GameFileCache::AddOrGet(const std::string& path,
bool GameFileCache::Update(
const std::vector<std::string>& all_game_paths,
std::function<void(const std::shared_ptr<const GameFile>&)> game_added_to_cache,
- std::function<void(const std::string&)> game_removed_from_cache)
+ std::function<void(const std::string&)> game_removed_from_cache,
+ const std::atomic_bool& processing_halted)
{
// Copy game paths into a set, except ones that match DiscIO::ShouldHideFromGameList.
// TODO: Prevent DoFileSearch from looking inside /files/ directories of DirectoryBlobs at all?
@@ -113,6 +114,9 @@ bool GameFileCache::Update(
auto end = m_cached_files.end();
while (it != end)
{
+ if (processing_halted)
+ break;
+
if (game_paths.erase((*it)->GetFilePath()))
{
++it;
@@ -134,6 +138,9 @@ bool GameFileCache::Update(
// aren't in m_cached_files, so we simply add all of them to m_cached_files.
for (const std::string& path : game_paths)
{
+ if (processing_halted)
+ break;
+
auto file = std::make_shared<GameFile>(path);
if (file->IsValid())
{
@@ -149,12 +156,16 @@ bool GameFileCache::Update(
}
bool GameFileCache::UpdateAdditionalMetadata(
- std::function<void(const std::shared_ptr<const GameFile>&)> game_updated)
+ std::function<void(const std::shared_ptr<const GameFile>&)> game_updated,
+ const std::atomic_bool& processing_halted)
{
bool cache_changed = false;
for (std::shared_ptr<GameFile>& file : m_cached_files)
{
+ if (processing_halted)
+ break;
+
const bool updated = UpdateAdditionalMetadata(&file);
cache_changed |= updated;
if (game_updated && updated)