mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-09 23:12:23 -04:00
CLI Merge: Only save database file when modified. (#2466)
* Merge: detect if database was changed. * Adding unit test. * Only saving on change.
This commit is contained in:
parent
a7dd9f19f4
commit
f06742cf41
2 changed files with 19 additions and 6 deletions
|
@ -84,14 +84,18 @@ int Merge::execute(const QStringList& arguments)
|
|||
}
|
||||
|
||||
Merger merger(db2.data(), db1.data());
|
||||
merger.merge();
|
||||
bool databaseChanged = merger.merge();
|
||||
|
||||
QString errorMessage = db1->saveToFile(args.at(0));
|
||||
if (!errorMessage.isEmpty()) {
|
||||
err << QObject::tr("Unable to save database to file : %1").arg(errorMessage) << endl;
|
||||
return EXIT_FAILURE;
|
||||
if (databaseChanged) {
|
||||
QString errorMessage = db1->saveToFile(args.at(0));
|
||||
if (!errorMessage.isEmpty()) {
|
||||
err << QObject::tr("Unable to save database to file : %1").arg(errorMessage) << endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
out << "Successfully merged the database files." << endl;
|
||||
} else {
|
||||
out << "Database was not modified by merge operation." << endl;
|
||||
}
|
||||
|
||||
out << "Successfully merged the database files." << endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue