diff --git a/transactions/kgpgdecrypt.h b/transactions/kgpgdecrypt.h --- a/transactions/kgpgdecrypt.h +++ b/transactions/kgpgdecrypt.h @@ -75,11 +75,14 @@ protected: QStringList command() const override; bool nextLine(const QString &line) override; + void finish() override; + private: int m_fileIndex; int m_plainLength; ///< length of decrypted plain text if given by GnuPG const QString m_outFilename; ///< name of file to write output to + bool decryptSuccess = false; //< flag to determine if decryption succeeded }; #endif // KGPGDECRYPT_H diff --git a/transactions/kgpgdecrypt.cpp b/transactions/kgpgdecrypt.cpp --- a/transactions/kgpgdecrypt.cpp +++ b/transactions/kgpgdecrypt.cpp @@ -113,7 +113,11 @@ { const QList &inputFiles = getInputFiles(); - if (!inputFiles.isEmpty()) { + if (line == QLatin1String("[GNUPG:] DECRYPTION_OKAY")) { + // Assume Gpg decryption was successful even if gpg returns + // a error code. + decryptSuccess = true; + } else if (!inputFiles.isEmpty()) { if (line == QLatin1String("[GNUPG:] BEGIN_DECRYPTION")) { emit statusMessage(i18nc("Status message 'Decrypting ' (operation starts)", "Decrypting %1", inputFiles.at(m_fileIndex).fileName())); emit infoProgress(2 * m_fileIndex + 1, inputFiles.count() * 2); @@ -137,3 +141,15 @@ return KGpgTextOrFileTransaction::nextLine(line); } + +void +KGpgDecrypt::finish() +{ + if (decryptSuccess) { + // Gpg error code is ignored. + // https://bugs.kde.org/show_bug.cgi?id=357462 + setSuccess(TS_OK); + } else { + KGpgTextOrFileTransaction::finish(); + } +}