Save backup: fix search not handling empty pattern

*backup time improv
This commit is contained in:
Vinicius Rangel 2024-09-23 08:28:22 -03:00
parent 05bfadc9eb
commit 25c38d143e
No known key found for this signature in database
GPG Key ID: A5B154D904B761D9
3 changed files with 15 additions and 5 deletions

View File

@ -115,6 +115,10 @@ static void BackupThreadBody() {
} }
LOG_DEBUG(Lib_SaveData, "Backing up the following directory: {} finished", LOG_DEBUG(Lib_SaveData, "Backing up the following directory: {} finished",
req.save_path.string()); req.save_path.string());
{
std::scoped_lock lk{g_backup_queue_mutex};
g_backup_queue.front().done = true;
}
std::this_thread::sleep_for(std::chrono::seconds(10)); // Don't backup too often std::this_thread::sleep_for(std::chrono::seconds(10)); // Don't backup too often
{ {
std::scoped_lock lk{g_backup_queue_mutex}; std::scoped_lock lk{g_backup_queue_mutex};
@ -206,8 +210,9 @@ WorkerStatus GetWorkerStatus() {
bool IsBackupExecutingFor(const std::filesystem::path& save_path) { bool IsBackupExecutingFor(const std::filesystem::path& save_path) {
std::scoped_lock lk{g_backup_queue_mutex}; std::scoped_lock lk{g_backup_queue_mutex};
return std::ranges::find(g_backup_queue, save_path, const auto& it =
[](const auto& v) { return v.save_path; }) != g_backup_queue.end(); std::ranges::find(g_backup_queue, save_path, [](const auto& v) { return v.save_path; });
return it != g_backup_queue.end() && !it->done;
} }
std::filesystem::path MakeBackupPath(const std::filesystem::path& save_path) { std::filesystem::path MakeBackupPath(const std::filesystem::path& save_path) {

View File

@ -28,6 +28,8 @@ enum class OrbisSaveDataEventType : u32 {
}; };
struct BackupRequest { struct BackupRequest {
bool done{};
OrbisUserServiceUserId user_id{}; OrbisUserServiceUserId user_id{};
std::string title_id{}; std::string title_id{};
std::string dir_name{}; std::string dir_name{};

View File

@ -581,6 +581,7 @@ Error PS4_SYSV_ABI sceSaveDataCheckBackupData(const OrbisSaveDataCheckBackupData
LOG_INFO(Lib_SaveData, "called with invalid parameter"); LOG_INFO(Lib_SaveData, "called with invalid parameter");
return Error::PARAMETER; return Error::PARAMETER;
} }
LOG_DEBUG(Lib_SaveData, "called with titleId={}", check->titleId->data.to_view());
const std::string_view title{check->titleId != nullptr ? std::string_view{check->titleId->data} const std::string_view title{check->titleId != nullptr ? std::string_view{check->titleId->data}
: std::string_view{g_game_serial}}; : std::string_view{g_game_serial}};
@ -801,9 +802,11 @@ Error PS4_SYSV_ABI sceSaveDataDirNameSearch(const OrbisSaveDataDirNameSearchCond
if (cond->dirName != nullptr) { if (cond->dirName != nullptr) {
// Filter names // Filter names
const auto pat = Common::ToLower(std::string_view{cond->dirName->data}); const auto pat = Common::ToLower(std::string_view{cond->dirName->data});
std::erase_if(dir_list, [&](const std::string& dir_name) { if (!pat.empty()) {
return !match(Common::ToLower(dir_name), pat); std::erase_if(dir_list, [&](const std::string& dir_name) {
}); return !match(Common::ToLower(dir_name), pat);
});
}
} }
std::unordered_map<std::string, PSF> map_dir_sfo; std::unordered_map<std::string, PSF> map_dir_sfo;