From 839a61ef59083ab610dd9cbe6c5560d24b3e3ec0 Mon Sep 17 00:00:00 2001 From: louib Date: Mon, 31 Jul 2017 10:17:08 -0400 Subject: [PATCH] Moving keyFile after password. (#830) * Moving keyFile after password. * Using tr() in unlockFromStdin. --- src/core/Database.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/core/Database.cpp b/src/core/Database.cpp index 2e9112c7c..4eb02ad1d 100644 --- a/src/core/Database.cpp +++ b/src/core/Database.cpp @@ -403,20 +403,10 @@ Database* Database::openDatabaseFile(QString fileName, CompositeKey key) Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilename) { CompositeKey compositeKey; - - if (!keyFilename.isEmpty()) { - FileKey fileKey; - QString errorMessage; - if (!fileKey.load(keyFilename, &errorMessage)) { - qCritical("Failed to load key file %s : %s", qPrintable(keyFilename), qPrintable(errorMessage)); - return nullptr; - } - compositeKey.addKey(fileKey); - } - QTextStream outputTextStream(stdout); + QTextStream errorTextStream(stderr); - outputTextStream << QString("Insert password to unlock " + databaseFilename + "\n> "); + outputTextStream << QObject::tr("Insert password to unlock %1: ").arg(databaseFilename); outputTextStream.flush(); QString line = Utils::getPassword(); @@ -424,6 +414,17 @@ Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilenam passwordKey.setPassword(line); compositeKey.addKey(passwordKey); + if (!keyFilename.isEmpty()) { + FileKey fileKey; + QString errorMessage; + if (!fileKey.load(keyFilename, &errorMessage)) { + errorTextStream << QObject::tr("Failed to load key file %1 : %2").arg(keyFilename).arg(errorMessage); + errorTextStream << endl; + return nullptr; + } + compositeKey.addKey(fileKey); + } + return Database::openDatabaseFile(databaseFilename, compositeKey); }