clear title result array when nxtc cache is deleted. rename sys-tweek -> sys-tweak.

This commit is contained in:
ITotalJustice
2025-06-22 21:34:36 +01:00
parent a4f0a97088
commit e039309a77
4 changed files with 26 additions and 10 deletions

View File

@@ -50,9 +50,12 @@ struct ThreadResultData {
using MetaEntries = std::vector<NsApplicationContentMetaStatus>; using MetaEntries = std::vector<NsApplicationContentMetaStatus>;
// starts background thread. // starts background thread (ref counted).
Result Init(); Result Init();
// closes the background thread.
void Exit(); void Exit();
// clears cache and empties the result array.
void Clear();
// adds new entry to queue. // adds new entry to queue.
void PushAsync(u64 app_id); void PushAsync(u64 app_id);

View File

@@ -25,6 +25,7 @@ struct ThreadData {
void Run(); void Run();
void Close(); void Close();
void Clear();
void PushAsync(u64 id); void PushAsync(u64 id);
auto GetAsync(u64 app_id) -> std::shared_ptr<ThreadResultData>; auto GetAsync(u64 app_id) -> std::shared_ptr<ThreadResultData>;
@@ -185,6 +186,13 @@ void ThreadData::Close() {
ueventSignal(&m_uevent); ueventSignal(&m_uevent);
} }
void ThreadData::Clear() {
SCOPED_MUTEX(&m_mutex_id);
SCOPED_MUTEX(&m_mutex_result);
m_result.clear();
nxtcWipeCache();
}
void ThreadData::PushAsync(u64 id) { void ThreadData::PushAsync(u64 id) {
SCOPED_MUTEX(&m_mutex_id); SCOPED_MUTEX(&m_mutex_id);
SCOPED_MUTEX(&m_mutex_result); SCOPED_MUTEX(&m_mutex_result);
@@ -294,14 +302,14 @@ auto ThreadData::Get(u64 app_id, bool* cached) -> std::shared_ptr<ThreadResultDa
} }
} }
// load override from sys-tweek. // load override from sys-tweak.
if (result->status == NacpLoadStatus::Loaded) { if (result->status == NacpLoadStatus::Loaded) {
const auto tweek_path = GetContentsPath(app_id); const auto tweak_path = GetContentsPath(app_id);
if (m_fs.DirExists(tweek_path)) { if (m_fs.DirExists(tweak_path)) {
log_write("[TITLE] found contents path: %s\n", tweek_path.s); log_write("[TITLE] found contents path: %s\n", tweak_path.s);
std::vector<u8> icon; std::vector<u8> icon;
m_fs.read_entire_file(fs::AppendPath(tweek_path, "icon.jpg"), icon); m_fs.read_entire_file(fs::AppendPath(tweak_path, "icon.jpg"), icon);
struct Overrides { struct Overrides {
std::string name; std::string name;
@@ -322,7 +330,7 @@ auto ThreadData::Get(u64 app_id, bool* cached) -> std::shared_ptr<ThreadResultDa
return 1; return 1;
}; };
ini_browse(cb, &overrides, fs::AppendPath(tweek_path, "config.ini")); ini_browse(cb, &overrides, fs::AppendPath(tweak_path, "config.ini"));
if (!icon.empty() && icon.size() < sizeof(NsApplicationControlData::icon)) { if (!icon.empty() && icon.size() < sizeof(NsApplicationControlData::icon)) {
log_write("[TITLE] overriding icon: %zu -> %zu\n", result->icon.size(), icon.size()); log_write("[TITLE] overriding icon: %zu -> %zu\n", result->icon.size(), icon.size());
@@ -407,6 +415,13 @@ void Exit() {
} }
} }
void Clear() {
SCOPED_MUTEX(&g_mutex);
if (g_thread_data) {
g_thread_data->Clear();
}
}
void PushAsync(u64 app_id) { void PushAsync(u64 app_id) {
SCOPED_MUTEX(&g_mutex); SCOPED_MUTEX(&g_mutex);
if (g_thread_data) { if (g_thread_data) {

View File

@@ -26,7 +26,6 @@
#include <cstring> #include <cstring>
#include <algorithm> #include <algorithm>
#include <minIni.h> #include <minIni.h>
#include <nxtc.h>
namespace sphaira::ui::menu::game { namespace sphaira::ui::menu::game {
namespace { namespace {
@@ -653,7 +652,7 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} {
"Back"_i18n, "Delete"_i18n, 0, [this](auto op_index){ "Back"_i18n, "Delete"_i18n, 0, [this](auto op_index){
if (op_index && *op_index) { if (op_index && *op_index) {
m_dirty = true; m_dirty = true;
nxtcWipeCache(); title::Clear();
App::PopToMenu(); App::PopToMenu();
} }
} }

View File

@@ -29,7 +29,6 @@
#include <minIni.h> #include <minIni.h>
#include <minizip/unzip.h> #include <minizip/unzip.h>
#include <minizip/zip.h> #include <minizip/zip.h>
#include <nxtc.h>
namespace sphaira::ui::menu::save { namespace sphaira::ui::menu::save {
namespace { namespace {