Skip to content

Commit

Permalink
By default do not display warning about backups made of the config file.
Browse files Browse the repository at this point in the history
Use the setting showConfigBackupWarning to change the default value.

Signed-off-by: Camila <hello@camila.codes>
  • Loading branch information
Camila committed Feb 1, 2023
1 parent 9ead33a commit 72fe5f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,11 @@ bool Application::configVersionMigration()
const auto versionChanged = previousVersion != currentVersion;
const auto downgrading = previousVersion > currentVersion;

// We want to message the user either for destructive changes,
// or if we're ignoring something and the client version changed.
const auto showWarning = !deleteKeys.isEmpty() || (!ignoreKeys.isEmpty() && versionChanged);

if (!versionChanged && !showWarning) {
if (!versionChanged && !(!deleteKeys.isEmpty() || (!ignoreKeys.isEmpty() && versionChanged))) {
return true;
}

// back up all old config file
// back up all old config files
QStringList backupFilesList;
QDir configDir(configFile.configPath());
const auto anyConfigFileNameList = configDir.entryInfoList({"*.cfg"}, QDir::Files);
Expand All @@ -171,7 +167,9 @@ bool Application::configVersionMigration()
}
}

if (showWarning || backupFilesList.count() > 0) {
// We want to message the user either for destructive changes,
// or if we're ignoring something and the client version changed.
if (configFile.showConfigBackupWarning() && backupFilesList.count() > 0) {
QMessageBox box(
QMessageBox::Warning,
APPLICATION_SHORTNAME,
Expand Down
6 changes: 6 additions & 0 deletions src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

namespace {
static constexpr char showMainDialogAsNormalWindowC[] = "showMainDialogAsNormalWindow";
static constexpr char showConfigBackupWarningC[] = "showConfigBackupWarning";

static constexpr char remotePollIntervalC[] = "remotePollInterval";
static constexpr char forceSyncIntervalC[] = "forceSyncInterval";
Expand Down Expand Up @@ -456,6 +457,11 @@ QString ConfigFile::backup(const QString &fileName) const
return backupFile;
}

bool ConfigFile::showConfigBackupWarning() const
{
return getValue(showConfigBackupWarningC, QString(), false).toBool();
}

QString ConfigFile::configFile() const
{
return configPath() + Theme::instance()->configFileName();
Expand Down
4 changes: 4 additions & 0 deletions src/libsync/configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class OWNCLOUDSYNC_EXPORT ConfigFile
* Returns the path of the new backup.
*/
[[nodiscard]] QString backup(const QString &fileName) const;
/**
* Display warning with a list of the config files that were backed up
*/
[[nodiscard]] bool showConfigBackupWarning() const;

bool exists();

Expand Down

0 comments on commit 72fe5f6

Please sign in to comment.