mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
Make pad and patches config savinng atomic
This commit is contained in:
parent
b3725baf5a
commit
75e66ab5e0
@ -387,7 +387,7 @@ bool cfg::node::from_string(const std::string& value, bool dynamic)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_log.fatal("Failed to load node: %s", error);
|
cfg_log.error("Failed to load node: %s", error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1064,13 +1064,6 @@ void patch_engine::save_config(const patch_map& patches_map)
|
|||||||
const std::string path = get_patch_config_path();
|
const std::string path = get_patch_config_path();
|
||||||
patch_log.notice("Saving patch config file %s", path);
|
patch_log.notice("Saving patch config file %s", path);
|
||||||
|
|
||||||
fs::file file(path, fs::rewrite);
|
|
||||||
if (!file)
|
|
||||||
{
|
|
||||||
patch_log.fatal("Failed to open patch config file %s (%s)", path, fs::g_tls_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
YAML::Emitter out;
|
YAML::Emitter out;
|
||||||
out << YAML::BeginMap;
|
out << YAML::BeginMap;
|
||||||
|
|
||||||
@ -1134,7 +1127,12 @@ void patch_engine::save_config(const patch_map& patches_map)
|
|||||||
|
|
||||||
out << YAML::EndMap;
|
out << YAML::EndMap;
|
||||||
|
|
||||||
file.write(out.c_str(), out.size());
|
fs::pending_file file(path);
|
||||||
|
|
||||||
|
if (!file.file || (file.file.write(out.c_str(), out.size()), !file.commit()))
|
||||||
|
{
|
||||||
|
patch_log.error("Failed to create patch config file %s (%s)", path, fs::g_tls_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void append_patches(patch_engine::patch_map& existing_patches, const patch_engine::patch_map& new_patches, usz& count, usz& total, std::stringstream* log_messages)
|
static void append_patches(patch_engine::patch_map& existing_patches, const patch_engine::patch_map& new_patches, usz& count, usz& total, std::stringstream* log_messages)
|
||||||
|
@ -68,11 +68,9 @@ void cfg_input::save(const std::string& title_id, const std::string& profile) co
|
|||||||
input_log.fatal("Failed to create path: %s (%s)", cfg_name, fs::g_tls_error);
|
input_log.fatal("Failed to create path: %s (%s)", cfg_name, fs::g_tls_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto cfg_file = fs::file(cfg_name, fs::rewrite))
|
fs::pending_file cfg_file(cfg_name);
|
||||||
{
|
|
||||||
cfg_file.write(to_string());
|
if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
input_log.error("Failed to save pad config to '%s'", cfg_name);
|
input_log.error("Failed to save pad config to '%s'", cfg_name);
|
||||||
}
|
}
|
||||||
|
@ -982,11 +982,9 @@ bool patch_manager_dialog::handle_json(const QByteArray& data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Overwrite current patch file
|
// Overwrite current patch file
|
||||||
if (fs::file patch_file = fs::file(path, fs::rewrite))
|
fs::pending_file patch_file(path);
|
||||||
{
|
|
||||||
patch_file.write(content);
|
if (!patch_file.file || (patch_file.file.write(content), !patch_file.commit()))
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
patch_log.error("Could not save new patches to %s (%s)", path, fs::g_tls_error);
|
patch_log.error("Could not save new patches to %s (%s)", path, fs::g_tls_error);
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user