From: Claudio Cambra Date: Tue, 20 Dec 2022 12:26:27 +0000 (+0100) Subject: Only add root-most encrypted folder to the blacklist X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~11^2~30^2~12 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fdaedc49145bad246a427d6c25c79ff8af310277;p=nextcloud-desktop.git Only add root-most encrypted folder to the blacklist Signed-off-by: Claudio Cambra --- diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 05e2a07a4..755f4c219 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -1335,10 +1335,32 @@ void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction dir, std::functio void Folder::removeLocalE2eFiles() { qCDebug(lcFolder) << "Removing local E2EE files"; + + const QDir folderRootDir(path()); QStringList e2eFoldersToBlacklist; - const auto couldGetFiles = _journal.getFilesBelowPath("", [&e2eFoldersToBlacklist](const SyncJournalFileRecord &rec) { + const auto couldGetFiles = _journal.getFilesBelowPath("", [this, &e2eFoldersToBlacklist, &folderRootDir](const SyncJournalFileRecord &rec) { + // We only want to add the root-most encrypted folder to the blacklist if (rec.isValid() && rec._isE2eEncrypted && rec.isDirectory()) { - e2eFoldersToBlacklist.append(rec._path); + QDir pathDir(rec._path); + bool parentPathEncrypted = false; + + while (pathDir.cdUp() && pathDir != folderRootDir) { + SyncJournalFileRecord rec; + const auto currentCanonicalPath = pathDir.canonicalPath(); + const auto ok = _journal.getFileRecord(currentCanonicalPath, &rec); + if (!ok) { + qCWarning(lcFolder) << "Failed to get file record for" << currentCanonicalPath; + } + + if (rec._isE2eEncrypted) { + parentPathEncrypted = true; + break; + } + } + + if (!parentPathEncrypted) { + e2eFoldersToBlacklist.append(rec._path); + } } });