Merge pull request #7772 from Robyt3/Config-Save-Error-Improvements

Improve error messages when saving settings fails
This commit is contained in:
Dennis Felsing 2024-01-07 13:55:38 +00:00 committed by GitHub
commit d6c10233ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -2997,7 +2997,11 @@ void CClient::Run()
{
// write down the config and quit
if(!m_pConfigManager->Save())
m_vWarnings.emplace_back(Localize("Saving ddnet-settings.cfg failed"));
{
char aWarning[128];
str_format(aWarning, sizeof(aWarning), Localize("Saving settings to '%s' failed"), CONFIG_FILE);
m_vWarnings.emplace_back(aWarning);
}
s_SavedConfig = true;
}

View file

@ -496,19 +496,27 @@ bool CConfigManager::Save()
WriteLine(pCommand);
}
if(m_Failed)
{
log_error("config", "ERROR: writing to %s failed", aConfigFileTmp);
}
if(io_sync(m_ConfigFile) != 0)
{
m_Failed = true;
log_error("config", "ERROR: synchronizing %s failed", aConfigFileTmp);
}
if(io_close(m_ConfigFile) != 0)
{
m_Failed = true;
log_error("config", "ERROR: closing %s failed", aConfigFileTmp);
}
m_ConfigFile = 0;
if(m_Failed)
{
log_error("config", "ERROR: writing to %s failed", aConfigFileTmp);
return false;
}