From efcd23eb06637566307b78484e0d627b7f27bf98 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 20 Dec 2022 20:16:06 +0100 Subject: [PATCH] Ensure blacklisted e2ee files get deleted Signed-off-by: Claudio Cambra --- src/gui/folder.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 60750e4d1..5a71c6a7c 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -1387,6 +1387,32 @@ void Folder::removeLocalE2eFiles() slotTerminateSync(); } + for (const auto &e2eFilePath : qAsConst(e2eFoldersToBlacklist)) { + if (!_journal.deleteFileRecord(e2eFilePath, true)) { + qCWarning(lcFolder) << "Failed to delete file record from local DB" << e2eFilePath + << "it might have already been deleted."; + continue; + } + + qCDebug(lcFolder) << "Removing local copy of" << e2eFilePath; + + const auto fullPath = QString(path() + e2eFilePath); + const QFileInfo pathInfo(fullPath); + + if (pathInfo.isDir() && pathInfo.exists()) { + QDir dir(fullPath); + if (!dir.removeRecursively()) { + qCWarning(lcFolder) << "Unable to remove directory and contents at:" << fullPath; + } + } else if (pathInfo.exists()) { + if (!QFile::remove(fullPath)) { + qCWarning(lcFolder) << "Unable to delete:" << fullPath; + } + } else { + qCWarning(lcFolder) << "Unable to delete:" << fullPath << "as it does not exist!"; + } + } + for (const auto &path : qAsConst(e2eFoldersToBlacklist)) { _journal.schedulePathForRemoteDiscovery(path); schedulePathForLocalDiscovery(path);