mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-04-25 16:15:11 -05:00
Rework save data deletion for Cache.
This commit is contained in:
parent
2e8d180d74
commit
6a1be48b16
|
|
@ -97,6 +97,9 @@ namespace data
|
|||
/// @brief Returns a pointer to the play statistics of applicationID
|
||||
PdmPlayStatistics *get_play_stats_by_id(uint64_t applicationID) noexcept;
|
||||
|
||||
/// @brief Erases the save info from the vector according to the pointer passed.
|
||||
void erase_save_info(const FsSaveDataInfo *saveInfo);
|
||||
|
||||
/// @brief Erases a UserDataEntry according to the application ID passed.
|
||||
/// @param applicationID ID of the save to erase.
|
||||
void erase_save_info_by_id(uint64_t applicationID);
|
||||
|
|
|
|||
|
|
@ -135,6 +135,16 @@ PdmPlayStatistics *data::User::get_play_stats_by_id(uint64_t applicationID) noex
|
|||
return &target->second.second;
|
||||
}
|
||||
|
||||
void data::User::erase_save_info(const FsSaveDataInfo *saveInfo)
|
||||
{
|
||||
auto find_save_info = [&](const data::UserDataEntry &entry) { return &entry.second.first == saveInfo; };
|
||||
|
||||
auto findInfo = std::find_if(m_userData.begin(), m_userData.end(), find_save_info);
|
||||
if (findInfo == m_userData.end()) { return; }
|
||||
|
||||
m_userData.erase(findInfo);
|
||||
}
|
||||
|
||||
void data::User::erase_save_info_by_id(uint64_t applicationID)
|
||||
{
|
||||
auto target = User::find_title_by_id(applicationID);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ void tasks::titleoptions::blacklist_title(sys::threadpool::JobData taskData)
|
|||
TitleOptionState *spawningState = castData->spawningState;
|
||||
|
||||
if (error::is_null(task)) { return; }
|
||||
if (error::is_null(titleInfo) || error::is_null(spawningState))
|
||||
else if (error::is_null(titleInfo) || error::is_null(spawningState))
|
||||
{
|
||||
task->complete();
|
||||
return;
|
||||
|
|
@ -50,7 +50,7 @@ void tasks::titleoptions::delete_all_local_backups_for_title(sys::threadpool::Jo
|
|||
data::TitleInfo *titleInfo = castData->titleInfo;
|
||||
|
||||
if (error::is_null(task)) { return; }
|
||||
if (error::is_null(titleInfo)) { TASK_FINISH_RETURN(task); }
|
||||
else if (error::is_null(titleInfo)) { TASK_FINISH_RETURN(task); }
|
||||
|
||||
const int popTicks = ui::PopMessageManager::DEFAULT_TICKS;
|
||||
const char *popSuccess = strings::get_by_name(strings::names::TITLEOPTION_POPS, 0);
|
||||
|
|
@ -89,7 +89,7 @@ void tasks::titleoptions::delete_all_remote_backups_for_title(sys::threadpool::J
|
|||
remote::Storage *remote = remote::get_remote_storage();
|
||||
|
||||
if (error::is_null(task)) { return; }
|
||||
if (error::is_null(titleInfo) || error::is_null(remote)) { TASK_FINISH_RETURN(task); }
|
||||
else if (error::is_null(titleInfo) || error::is_null(remote)) { TASK_FINISH_RETURN(task); }
|
||||
|
||||
const char *title = titleInfo->get_title();
|
||||
const std::string_view remoteTitle = remote->supports_utf8() ? titleInfo->get_title() : titleInfo->get_path_safe_title();
|
||||
|
|
@ -205,7 +205,7 @@ void tasks::titleoptions::delete_save_data_from_system(sys::threadpool::JobData
|
|||
}
|
||||
|
||||
const uint64_t applicationID = titleInfo->get_application_id();
|
||||
user->erase_save_info_by_id(applicationID);
|
||||
user->erase_save_info(saveInfo);
|
||||
titleSelect->refresh();
|
||||
spawningState->close_on_update();
|
||||
task->complete();
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ void tasks::useroptions::delete_all_save_data_for_user(sys::threadpool::JobData
|
|||
const char *statusFormat = strings::get_by_name(strings::names::USEROPTION_STATUS, 1);
|
||||
const char *popFailed = strings::get_by_name(strings::names::SAVECREATE_POPS, 2);
|
||||
|
||||
std::vector<uint64_t> applicationIDs{};
|
||||
std::vector<const FsSaveDataInfo *> saveInfos{};
|
||||
const int titleCount = user->get_total_data_entries();
|
||||
for (int i = 0; i < titleCount; i++)
|
||||
{
|
||||
|
|
@ -192,10 +192,12 @@ void tasks::useroptions::delete_all_save_data_for_user(sys::threadpool::JobData
|
|||
ui::PopMessageManager::push_message(popTicks, popFailed);
|
||||
continue;
|
||||
}
|
||||
applicationIDs.push_back(applicationID);
|
||||
|
||||
saveInfos.push_back(saveInfo);
|
||||
}
|
||||
|
||||
for (const uint64_t applicationID : applicationIDs) { user->erase_save_info_by_id(applicationID); }
|
||||
for (const FsSaveDataInfo *saveInfo : saveInfos) { user->erase_save_info(saveInfo); }
|
||||
|
||||
spawningState->refresh_required();
|
||||
task->complete();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user