Moving keyFile after password. (#830)

* Moving keyFile after password.

* Using tr() in unlockFromStdin.
This commit is contained in:
louib 2017-07-31 10:17:08 -04:00 committed by GitHub
parent fe877486ff
commit 839a61ef59

View File

@ -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);
}