From: Claudio Cambra Date: Thu, 3 Aug 2023 07:34:39 +0000 (+0800) Subject: Deduplicate whitelistFolderPath and blacklistFolderPath X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~92^2^2~57^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6d5662152068fee1b7f4379c5e8b2a0e4f7df9fc;p=nextcloud-desktop.git Deduplicate whitelistFolderPath and blacklistFolderPath Signed-off-by: Claudio Cambra --- diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index efbf46d90..f41a31424 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -1259,7 +1259,7 @@ Folder *FolderMan::folderForPath(const QString &path) return it != folders.cend() ? *it : nullptr; } -void FolderMan::whitelistFolderPath(const QString &path) +void FolderMan::addFolderToSelectiveSyncList(const QString &path, const SyncJournalDb::SelectiveSyncListType list) { const auto folder = folderForPath(path); if (!folder) { @@ -1268,19 +1268,27 @@ void FolderMan::whitelistFolderPath(const QString &path) const QString folderPath = folder->cleanPath() + QLatin1Char('/'); const auto relPath = path.mid(folderPath.length()); - folder->whitelistPath(relPath); + + switch (list) { + case SyncJournalDb::SelectiveSyncListType::SelectiveSyncWhiteList: + folder->whitelistPath(relPath); + break; + case SyncJournalDb::SelectiveSyncListType::SelectiveSyncBlackList: + folder->blacklistPath(relPath); + break; + default: + Q_UNREACHABLE(); + } } -void FolderMan::blacklistFolderPath(const QString &path) +void FolderMan::whitelistFolderPath(const QString &path) { - const auto folder = folderForPath(path); - if (!folder) { - return; - } + addFolderToSelectiveSyncList(path, SyncJournalDb::SelectiveSyncListType::SelectiveSyncWhiteList); +} - const QString folderPath = folder->cleanPath() + QLatin1Char('/'); - const auto relPath = path.mid(folderPath.length()); - folder->blacklistPath(relPath); +void FolderMan::blacklistFolderPath(const QString &path) +{ + addFolderToSelectiveSyncList(path, SyncJournalDb::SelectiveSyncListType::SelectiveSyncBlackList); } QStringList FolderMan::findFileInLocalFolders(const QString &relPath, const AccountPtr acc) diff --git a/src/gui/folderman.h b/src/gui/folderman.h index a79f11193..684ba2982 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -358,6 +358,8 @@ private: [[nodiscard]] bool isSwitchToVfsNeeded(const FolderDefinition &folderDefinition) const; + void addFolderToSelectiveSyncList(const QString &path, const SyncJournalDb::SelectiveSyncListType list); + QSet _disabledFolders; Folder::Map _folderMap; QString _folderConfigPath;