Don't overwrite config if the new one was not successfully written (#10284)

* Don't overwrite config if the new one was not successfully written

The errors weren't being checked, now they are.

Fixes #10283
This commit is contained in:
coryrc
2025-08-10 18:59:01 -07:00
committed by GitHub
parent 9ae20024aa
commit 53440fd390

View File

@@ -837,6 +837,10 @@ void AppConfig::save()
#endif
c.close();
if (c.fail()) {
BOOST_LOG_TRIVIAL(error) << "Failed to write new configuration to " << path_pid << "; aborting attempt to overwrite original configuration";
return;
}
#ifdef WIN32
// Make a backup of the configuration file before copying it to the final destination.
@@ -1042,6 +1046,10 @@ void AppConfig::save()
c << appconfig_md5_hash_line(config_str);
#endif
c.close();
if (c.fail()) {
BOOST_LOG_TRIVIAL(error) << "Failed to write new configuration to " << path_pid << "; aborting attempt to overwrite original configuration";
return;
}
#ifdef WIN32
// Make a backup of the configuration file before copying it to the final destination.