Avoid double file extension replacement in backup filename

This commit is contained in:
Janek Bevendorff 2018-02-27 15:28:12 +01:00
parent c13c6ade29
commit e1558d6300

View File

@ -570,10 +570,11 @@ QString Database::writeDatabase(QIODevice* device)
* @param filePath Path to the file to backup
* @return
*/
bool Database::backupDatabase(QString filePath)
{
QString backupFilePath = filePath;
auto re = QRegularExpression("(?:\\.kdbx)?$", QRegularExpression::CaseInsensitiveOption);
auto re = QRegularExpression("\\.kdbx$|(?<!\\.kdbx)$", QRegularExpression::CaseInsensitiveOption);
backupFilePath.replace(re, ".old.kdbx");
QFile::remove(backupFilePath);
return QFile::copy(filePath, backupFilePath);