From e5504a060d4af12682abbdf674834397d566502a Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Fri, 10 Aug 2018 11:10:44 -0400 Subject: [PATCH] registered_cache: Fix missing reading from yuzu_meta --- src/core/file_sys/registered_cache.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 3e77061710..665126c1c4 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -129,14 +129,12 @@ VirtualFile RegisteredCache::GetFileAtID(NcaID id) const { return file; } -boost::optional RegisteredCache::GetNcaIDFromMetadata(u64 title_id, - ContentRecordType type) const { - if (type == ContentRecordType::Meta && meta_id.find(title_id) != meta_id.end()) - return meta_id.at(title_id); - if (meta.find(title_id) == meta.end()) +static boost::optional CheckMapForContentRecord( + const boost::container::flat_map& map, u64 title_id, ContentRecordType type) { + if (map.find(title_id) == map.end()) return boost::none; - const auto& cnmt = meta.at(title_id); + const auto& cnmt = map.at(title_id); const auto iter = std::find_if(cnmt.GetContentRecords().begin(), cnmt.GetContentRecords().end(), [type](const ContentRecord& rec) { return rec.type == type; }); @@ -146,6 +144,17 @@ boost::optional RegisteredCache::GetNcaIDFromMetadata(u64 title_id, return boost::make_optional(iter->nca_id); } +boost::optional RegisteredCache::GetNcaIDFromMetadata(u64 title_id, + ContentRecordType type) const { + if (type == ContentRecordType::Meta && meta_id.find(title_id) != meta_id.end()) + return meta_id.at(title_id); + + const auto res1 = CheckMapForContentRecord(yuzu_meta, title_id, type); + if (res1 != boost::none) + return res1; + return CheckMapForContentRecord(meta, title_id, type); +} + std::vector RegisteredCache::AccumulateFiles() const { std::vector ids; for (const auto& d2_dir : dir->GetSubdirectories()) { @@ -398,7 +407,7 @@ bool RegisteredCache::RawInstallNCA(std::shared_ptr nca, boost::optional