]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Add methods to Folder so that other classes can easily add folder paths to white...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 5 Jul 2023 09:16:03 +0000 (17:16 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 4 Aug 2023 09:40:39 +0000 (17:40 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/folder.cpp
src/gui/folder.h

index 5d6caf2f10d011b372a12599174a4cb6f4f6b3ef..29c4e901989ecbd12ecadec5aea71aee5a7df1e4 100644 (file)
@@ -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);
index 78f4023f07ebd7a7fd8a5945928d1cff2e7b3bc9..5ffbde52d143a18a8255e225a770c00982f1b1d9 100644 (file)
@@ -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 "/"