From 278f92b189ece58dee2036450ac029e3599fdb1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Wed, 15 Nov 2023 11:51:51 +0100 Subject: qt: Remove left-over partial files more persistently * lang/qt/src/Makefile.am: Add new files. * lang/qt/src/cleaner.cpp, lang/qt/src/cleaner.h: New. * lang/qt/src/util.cpp (PartialFileGuard::~PartialFileGuard): Call Cleaner::removeFile instead of removeFile. * lang/qt/src/util.cpp, lang/qt/src/util.h (removeFile): Remove. -- If the initial attempt to remove the file fails then a Cleaner is created that tries to remove the file at regular intervals (10 s) and on destruction (which happens on application shutdown). GnuPG-bug-id: 6584 --- lang/qt/src/util.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'lang/qt/src/util.cpp') diff --git a/lang/qt/src/util.cpp b/lang/qt/src/util.cpp index 297c76a6..4b437ffb 100644 --- a/lang/qt/src/util.cpp +++ b/lang/qt/src/util.cpp @@ -37,6 +37,7 @@ #include "util.h" +#include "cleaner.h" #include "qgpgme_debug.h" #include @@ -68,17 +69,6 @@ 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"; - } - } -} - /** * Generates a string of random characters for the file names of temporary files. * Never use this for generating passwords or similar use cases requiring highly @@ -157,7 +147,7 @@ PartialFileGuard::PartialFileGuard(const QString &fileName) PartialFileGuard::~PartialFileGuard() { if (!mTempFileName.isEmpty()) { - removeFile(mTempFileName); + Cleaner::removeFile(mTempFileName); } } -- cgit v1.2.3