From 8d8985bda1747a18b3b1378ea7c627302a61464a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Fri, 27 Oct 2023 11:27:29 +0200 Subject: qt: Refactor removal of output file on cancel or error * lang/qt/src/util.h, lang/qt/src/util.cpp (removeFile): New. * lang/qt/src/qgpgmeencryptarchivejob.cpp (encrypt): Move removal of output file from here (encrypt_to_filename): ... to here and use new function. * lang/qt/src/qgpgmesignarchivejob.cpp (sign): Move removal of output file from here (sign_to_filename): ... to here and use new function. * lang/qt/src/qgpgmesignencryptarchivejob.cpp (sign_encrypt): Move removal of output file from here (sign_encrypt_to_filename): ... to here and use new function. -- GnuPG-bug-id: 6721 --- lang/qt/src/util.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lang/qt/src/util.cpp') diff --git a/lang/qt/src/util.cpp b/lang/qt/src/util.cpp index d4190eb8..a9a70290 100644 --- a/lang/qt/src/util.cpp +++ b/lang/qt/src/util.cpp @@ -37,6 +37,10 @@ #include "util.h" +#include "qgpgme_debug.h" + +#include + #include #include @@ -61,3 +65,14 @@ QStringList toFingerprints(const std::vector &keys) }); return fprs; } + +void removeFile(const QString &fileName) +{ + if (QFile::exists(fileName)) { + if (QFile::remove(fileName)) { + qCDebug(QGPGME_LOG) << __func__ << "- Removed file" << fileName; + } else { + qCDebug(QGPGME_LOG) << __func__ << "- Removing file" << fileName << "failed"; + } + } +} -- cgit v1.2.3