From 6edba3820b5713f7549a0f1eeab828d94a60010f Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 9 Jul 2023 18:15:55 +1000 Subject: [PATCH] GameList: Don't repeatedly scan invalid files every startup --- pcsx2/GameList.cpp | 23 +++++++++++++++++++++-- pcsx2/GameList.h | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pcsx2/GameList.cpp b/pcsx2/GameList.cpp index a04a4581fd..f2f16b7940 100644 --- a/pcsx2/GameList.cpp +++ b/pcsx2/GameList.cpp @@ -312,7 +312,16 @@ bool GameList::GetIsoListEntry(const std::string& path, GameList::Entry* entry) case CDVD_TYPE_ILLEGAL: default: - return false; + { + // Create empty invalid entry, so we don't repeatedly scan it every time. + entry->type = EntryType::Invalid; + entry->path = path; + entry->total_size = 0; + entry->compatibility_rating = CompatibilityRating::Unknown; + entry->title.clear(); + entry->region = Region::Other; + return true; + } } entry->path = path; @@ -624,6 +633,10 @@ bool GameList::AddFileFromCache(const std::string& path, std::time_t timestamp, if (!GetGameListEntryFromCache(path, &entry) || entry.last_modified_time != timestamp) return false; + // Skip over invalid entries. + if (entry.type == EntryType::Invalid) + return true; + auto iter = UnorderedStringMapFind(played_time_map, entry.serial); if (iter != played_time_map.end()) { @@ -647,7 +660,6 @@ bool GameList::ScanFile( if (!PopulateEntryFromPath(path, &entry)) return false; - entry.path = std::move(path); entry.last_modified_time = timestamp; if (s_cache_write_stream || OpenCacheForWriting()) @@ -656,6 +668,13 @@ bool GameList::ScanFile( Console.Warning("Failed to write entry '%s' to cache", entry.path.c_str()); } + if (entry.type == EntryType::Invalid) + { + // don't add invalid entries to list + lock.lock(); + return true; + } + auto iter = UnorderedStringMapFind(played_time_map, entry.serial); if (iter != played_time_map.end()) { diff --git a/pcsx2/GameList.h b/pcsx2/GameList.h index 8b77c2650e..5bd4bbc73d 100644 --- a/pcsx2/GameList.h +++ b/pcsx2/GameList.h @@ -40,6 +40,7 @@ namespace GameList PS2Disc, PS1Disc, ELF, + Invalid, Count };