From 2bcefd61057a21fc2021ce186abf2e973ff76cef Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 5 Jul 2023 17:16:03 +0800 Subject: [PATCH] Add methods to Folder so that other classes can easily add folder paths to white/blacklists Signed-off-by: Claudio Cambra --- src/gui/folder.cpp | 24 ++++++++++++++++++++++++ src/gui/folder.h | 5 +++++ 2 files changed, 29 insertions(+) diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 5d6caf2f1..29c4e9019 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -13,6 +13,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ +#include "common/syncjournaldb.h" #include "config.h" #include "account.h" @@ -842,6 +843,29 @@ bool Folder::pathIsIgnored(const QString &path) const return false; } +void Folder::appendPathToSelectiveSyncList(const QString &path, const SyncJournalDb::SelectiveSyncListType listType) +{ + const auto folderPath = trailingSlashPath(path); + const auto journal = journalDb(); + auto ok = false; + auto list = journal->getSelectiveSyncList(listType, &ok); + + if (ok) { + list.append(folderPath); + journal->setSelectiveSyncList(listType, list); + } +} + +void Folder::whitelistPath(const QString &path) +{ + appendPathToSelectiveSyncList(path, SyncJournalDb::SelectiveSyncWhiteList); +} + +void Folder::blacklistPath(const QString &path) +{ + appendPathToSelectiveSyncList(path, SyncJournalDb::SelectiveSyncBlackList); +} + bool Folder::isFileExcludedAbsolute(const QString &fullPath) const { return _engine->excludedFiles().isExcluded(fullPath, path(), _definition.ignoreHiddenFiles); diff --git a/src/gui/folder.h b/src/gui/folder.h index 78f4023f0..5ffbde52d 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -301,6 +301,9 @@ public: QString fileFromLocalPath(const QString &localPath) const; + void whitelistPath(const QString &path); + void blacklistPath(const QString &path); + signals: void syncStateChange(); void syncStarted(); @@ -468,6 +471,8 @@ private: void correctPlaceholderFiles(); + void appendPathToSelectiveSyncList(const QString &path, const SyncJournalDb::SelectiveSyncListType listType); + AccountStatePtr _accountState; FolderDefinition _definition; QString _canonicalLocalPath; // As returned with QFileInfo:canonicalFilePath. Always ends with "/"