GameList: Don't repeatedly scan invalid files every startup

This commit is contained in:
Stenzek 2023-07-09 18:15:55 +10:00 committed by Connor McLaughlin
parent db1e1bcc1f
commit 6edba3820b
2 changed files with 22 additions and 2 deletions

View File

@ -312,7 +312,16 @@ bool GameList::GetIsoListEntry(const std::string& path, GameList::Entry* entry)
case CDVD_TYPE_ILLEGAL: case CDVD_TYPE_ILLEGAL:
default: 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; 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) if (!GetGameListEntryFromCache(path, &entry) || entry.last_modified_time != timestamp)
return false; return false;
// Skip over invalid entries.
if (entry.type == EntryType::Invalid)
return true;
auto iter = UnorderedStringMapFind(played_time_map, entry.serial); auto iter = UnorderedStringMapFind(played_time_map, entry.serial);
if (iter != played_time_map.end()) if (iter != played_time_map.end())
{ {
@ -647,7 +660,6 @@ bool GameList::ScanFile(
if (!PopulateEntryFromPath(path, &entry)) if (!PopulateEntryFromPath(path, &entry))
return false; return false;
entry.path = std::move(path);
entry.last_modified_time = timestamp; entry.last_modified_time = timestamp;
if (s_cache_write_stream || OpenCacheForWriting()) 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()); 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); auto iter = UnorderedStringMapFind(played_time_map, entry.serial);
if (iter != played_time_map.end()) if (iter != played_time_map.end())
{ {

View File

@ -40,6 +40,7 @@ namespace GameList
PS2Disc, PS2Disc,
PS1Disc, PS1Disc,
ELF, ELF,
Invalid,
Count Count
}; };