Skip to content

Commit

Permalink
ensureSettingsFileExists func for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
firthm01 committed Dec 14, 2023
1 parent ba3bc28 commit 6a97ce7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion shared/update_check_settings_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ UpdateCheckerSettingsFile::UpdateCheckerSettingsFile()
settingsFile = ResourcePaths::getSettingsDirectory(true).getChildFile("UpdateCheck.settings");
if (!settingsFileExists()) {
// No settings file - perhaps first run?
if (saveSettings() && settingsFileExists()) {
if (ensureSettingsFileExists()) {
// Settings file is writable so probably was just first run.
// Set autocheck on initially.
setAutoCheckEnabled(true);
Expand Down Expand Up @@ -97,3 +97,12 @@ bool UpdateCheckerSettingsFile::settingsFileExists()
{
return settingsFile.existsAsFile();
}

bool UpdateCheckerSettingsFile::ensureSettingsFileExists()
{
bool success = settingsFileExists();
if (!success) {
success = saveSettings() && settingsFileExists();
}
return success;
}
1 change: 1 addition & 0 deletions shared/update_check_settings_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class UpdateCheckerSettingsFile {
bool loadSettings();
bool saveSettings();
bool settingsFileExists();
bool ensureSettingsFileExists();

bool settingAutoCheckEnabled{ false };
Version settingLastReportedVersion;
Expand Down

0 comments on commit 6a97ce7

Please sign in to comment.