From 8794e623d99d6179ab15f76ddf473002d112fc3a Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Sun, 5 Jul 2020 10:38:34 -0400 Subject: [PATCH] Remove global system instance and address feedback --- src/core/file_sys/registered_cache.cpp | 22 +++++++++------------- src/core/file_sys/registered_cache.h | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 39bfbdfd3..0f4d52d35 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -547,7 +547,7 @@ InstallResult RegisteredCache::InstallEntry(const XCI& xci, bool overwrite_if_ex return InstallEntry(*xci.GetSecurePartitionNSP(), overwrite_if_exists, copy); } -bool RegisteredCache::RemoveExistingEntry(const u64 title_id) { +bool RegisteredCache::RemoveExistingEntry(u64 title_id) { const auto delete_nca = [this](const NcaID& id) { const auto path = GetRelativePathFromNcaID(id, false, true, false); @@ -566,25 +566,23 @@ bool RegisteredCache::RemoveExistingEntry(const u64 title_id) { return res; }; - // Get the Content Provider - const auto& installed = Core::System::GetInstance().GetContentProvider(); // If an update exists, remove - if (installed.HasEntry(title_id, ContentRecordType::Meta)) { + if (HasEntry(title_id, ContentRecordType::Meta)) { LOG_INFO(Loader, "Previous Update (v{}) for title_id={:016X} detected! Attempting to remove...", - installed.GetEntryVersion(title_id).value_or(0), title_id); + GetEntryVersion(title_id).value_or(0), title_id); // Get all the ncas associated with the current update CNMT and delete them - const auto& meta_old_id = + const auto meta_old_id = GetNcaIDFromMetadata(title_id, ContentRecordType::Meta).value_or(NcaID{}); - const auto& program_id = + const auto program_id = GetNcaIDFromMetadata(title_id, ContentRecordType::Program).value_or(NcaID{}); - const auto& data_id = + const auto data_id = GetNcaIDFromMetadata(title_id, ContentRecordType::Data).value_or(NcaID{}); - const auto& control_id = + const auto control_id = GetNcaIDFromMetadata(title_id, ContentRecordType::Control).value_or(NcaID{}); - const auto& html_id = + const auto html_id = GetNcaIDFromMetadata(title_id, ContentRecordType::HtmlDocument).value_or(NcaID{}); - const auto& legal_id = + const auto legal_id = GetNcaIDFromMetadata(title_id, ContentRecordType::LegalInformation).value_or(NcaID{}); delete_nca(meta_old_id); @@ -618,9 +616,7 @@ InstallResult RegisteredCache::InstallEntry(const NSP& nsp, bool overwrite_if_ex const auto cnmt_file = section0->GetFiles()[0]; const CNMT cnmt(cnmt_file); - // Get the title id stored within the CNMT const auto title_id = cnmt.GetTitleID(); - // Removes an entry if it exists const auto result = RemoveExistingEntry(title_id); // Install Metadata File diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index 8598f0543..3459c695b 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h @@ -156,7 +156,7 @@ public: std::optional title_id = {}) const override; // Removes an existing entry based on title id - bool RemoveExistingEntry(const u64 title_id); + bool RemoveExistingEntry(u64 title_id); // Raw copies all the ncas from the xci/nsp to the csache. Does some quick checks to make sure // there is a meta NCA and all of them are accessible.