rpcs3/rpcs3/Loader/iso_cache.h
Vishrut Sachan d93d9b2c5a
game_list: Fix ISO cache bypass in is_from_yml branch for multi-game ISOs (#18683)
Fixes regression from #18546 and #18679.

## Problem
The is_from_yml ISO branch constructed iso_archive unconditionally,
bypassing the cache check inside add_game, making the cache write-only
for yml-sourced ISOs.

## Fix
Added a lightweight index cache entry (iso_path + "//index") storing the
subdir list + mtime. On hit, skips archive construction entirely. On
miss, walks as before and writes the index
2026-05-05 11:14:16 +02:00

37 lines
1.1 KiB
C++

#pragma once
#include "Loader/PSF.h"
#include "Utilities/File.h"
#include "util/types.hpp"
#include <string>
#include <unordered_set>
#include <vector>
// Cached metadata extracted from an ISO during game list scanning.
struct iso_metadata_cache_entry
{
s64 mtime = 0;
std::vector<u8> psf_data{};
std::string icon_path{};
std::vector<u8> icon_data{};
std::string movie_path{};
std::string audio_path{};
std::vector<std::string> subdirs{};
};
namespace iso_cache
{
// Returns false if no valid cache entry exists or mtime has changed.
bool load(const std::string& iso_path, const std::string& cache_key, iso_metadata_cache_entry& out_entry);
// Persists a populated cache entry to disk.
void save(const std::string& iso_path, const std::string& cache_key, const iso_metadata_cache_entry& entry);
bool load_index(const std::string& iso_path, std::vector<std::string>& out_subdirs);
void save_index(const std::string& iso_path, const std::vector<std::string>& subdirs);
// Remove cache entries for ISOs that are no longer in the scanned set.
void cleanup(const std::unordered_set<std::string>& valid_iso_paths);
}