mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Using saveToFile in Merge command.
This commit is contained in:
parent
f3f6f6a493
commit
46f7d97176
@ -22,12 +22,10 @@
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCoreApplication>
|
||||
#include <QSaveFile>
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "format/KeePass2Writer.h"
|
||||
#include "gui/UnlockDatabaseDialog.h"
|
||||
|
||||
int Merge::execute(int argc, char** argv)
|
||||
@ -95,26 +93,13 @@ int Merge::execute(int argc, char** argv)
|
||||
}
|
||||
|
||||
db1->merge(db2);
|
||||
|
||||
QSaveFile saveFile(args.at(0));
|
||||
if (!saveFile.open(QIODevice::WriteOnly)) {
|
||||
qCritical("Unable to open file %s for writing.", qPrintable(args.at(0)));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
KeePass2Writer writer;
|
||||
writer.writeDatabase(&saveFile, db1);
|
||||
|
||||
if (writer.hasError()) {
|
||||
qCritical("Error while updating the database:\n%s\n", qPrintable(writer.errorString()));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!saveFile.commit()) {
|
||||
qCritical("Error while updating the database:\n%s\n", qPrintable(writer.errorString()));
|
||||
QString errorMessage = db1->saveToFile(args.at(0));
|
||||
if (!errorMessage.isEmpty()) {
|
||||
qCritical("Unable to save database to file : %s", qPrintable(errorMessage));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
out << "Successfully merged the database files.\n";
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user