Skip to content

Commit

Permalink
Minor changes to address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
droidmonkey committed Jan 28, 2018
1 parent 5dad2da commit d850e96
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/core/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilenam
*
* This function uses QTemporaryFile instead of QSaveFile due to a bug
* in Qt (https://bugreports.qt.io/browse/QTBUG-57299) that may prevent
* the QSaveFile from renaming itself when using DropBox, Drive, or OneDrive.
* the QSaveFile from renaming itself when using Dropbox, Drive, or OneDrive.
*
* The risk in using QTemporaryFile is that the rename function is not atomic
* and may result in loss of data if there is a crash or power loss at the
Expand Down Expand Up @@ -554,19 +554,16 @@ QString Database::writeDatabase(QIODevice* device)

/**
* Remove the old backup and replace it with a new one
* backups are named <filename>.old.kdbx4
* backups are named <filename>.old.kdbx
*
* @param filePath Path to the file to backup
* @return
*/
bool Database::backupDatabase(QString filePath)
{
QString backupFilePath = filePath;
backupFilePath.replace(".kdbx", ".old.kdbx", Qt::CaseInsensitive);
if (!backupFilePath.endsWith(".old.kdbx")) {
// Fallback in case of poorly named file
backupFilePath = filePath + ".old";
}
auto re = QRegularExpression("(?:\\.kdbx)?$", QRegularExpression::CaseInsensitiveOption);
backupFilePath.replace(re, ".old.kdbx");
QFile::remove(backupFilePath);
return QFile::copy(filePath, backupFilePath);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/DatabaseTabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ bool DatabaseTabWidget::saveDatabase(Database* db, QString filePath)

dbStruct.dbWidget->blockAutoReload(true);
// TODO: Make this async, but lock out the database widget to prevent re-entrance
bool useAtomicSaves = config()->get("UseAtomicSaves").toBool();
bool useAtomicSaves = config()->get("UseAtomicSaves", true).toBool();
QString errorMessage = db->saveToFile(filePath, useAtomicSaves, config()->get("BackupBeforeSave").toBool());
dbStruct.dbWidget->blockAutoReload(false);

Expand Down
2 changes: 1 addition & 1 deletion src/gui/SettingsWidgetGeneral.ui
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<item>
<widget class="QCheckBox" name="useAtomicSavesCheckBox">
<property name="text">
<string>Safely save database files (may be incompatible with DropBox, etc)</string>
<string>Safely save database files (may be incompatible with Dropbox, etc)</string>
</property>
<property name="checked">
<bool>true</bool>
Expand Down

0 comments on commit d850e96

Please sign in to comment.