Only backup database if schema version is correct

This commit is contained in:
Jonas Kvinge 2020-11-09 23:10:43 +01:00
parent 3821680817
commit 30c336726b
1 changed files with 4 additions and 2 deletions

View File

@ -519,11 +519,13 @@ void Database::DoBackup() {
QSqlDatabase db(this->Connect());
if (!db.isOpen()) return;
// Before we overwrite anything, make sure the database is not corrupt
QMutexLocker l(&mutex_);
const bool ok = IntegrityCheck(db);
if (ok) {
const bool ok = IntegrityCheck(db);
if (ok && SchemaVersion(&db) == kSchemaVersion) {
BackupFile(db.databaseName());
}