Skip to content

Commit

Permalink
GameList: Don't repeatedly scan invalid files every startup
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Jul 9, 2023
1 parent db1e1bc commit 6edba38
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
23 changes: 21 additions & 2 deletions pcsx2/GameList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
{
Expand All @@ -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())
Expand All @@ -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())
{
Expand Down
1 change: 1 addition & 0 deletions pcsx2/GameList.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace GameList
PS2Disc,
PS1Disc,
ELF,
Invalid,
Count
};

Expand Down

0 comments on commit 6edba38

Please sign in to comment.