mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Only delete old file when the new one has been saved successfully.
This commit is contained in:
parent
7880c0e4f5
commit
e39827d777
@ -174,7 +174,7 @@ void DatabaseTabWidget::saveDatabaseAs(Database* db)
|
|||||||
QString fileName = fileDialog()->getSaveFileName(m_window, tr("Save database as"),
|
QString fileName = fileDialog()->getSaveFileName(m_window, tr("Save database as"),
|
||||||
oldFileName, tr("KeePass 2 Database").append(" (*.kdbx)"));
|
oldFileName, tr("KeePass 2 Database").append(" (*.kdbx)"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
delete dbStruct.file;
|
QFile* oldFile = dbStruct.file;
|
||||||
QScopedPointer<QFile> file(new QFile(fileName));
|
QScopedPointer<QFile> file(new QFile(fileName));
|
||||||
// TODO error handling
|
// TODO error handling
|
||||||
if (!file->open(QIODevice::ReadWrite)) {
|
if (!file->open(QIODevice::ReadWrite)) {
|
||||||
@ -184,6 +184,7 @@ void DatabaseTabWidget::saveDatabaseAs(Database* db)
|
|||||||
// TODO ensure that the data is actually written to disk
|
// TODO ensure that the data is actually written to disk
|
||||||
m_writer.writeDatabase(dbStruct.file, db);
|
m_writer.writeDatabase(dbStruct.file, db);
|
||||||
dbStruct.file->flush();
|
dbStruct.file->flush();
|
||||||
|
delete oldFile;
|
||||||
|
|
||||||
dbStruct.modified = false;
|
dbStruct.modified = false;
|
||||||
dbStruct.fileName = QFileInfo(fileName).absoluteFilePath();
|
dbStruct.fileName = QFileInfo(fileName).absoluteFilePath();
|
||||||
|
Loading…
Reference in New Issue
Block a user