]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Default to adding existing now big folders to whitelist when undecided
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 5 Jul 2023 18:47:05 +0000 (02:47 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 4 Aug 2023 09:40:41 +0000 (17:40 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/folder.cpp
src/gui/folderman.cpp
src/gui/folderman.h
src/gui/tray/activitylistmodel.cpp

index d40017dec3098e5cf0c540bd2c4741655ca96f48..934acd75196555b9d7abdd96801fe712466f7562 100644 (file)
@@ -1263,6 +1263,16 @@ void Folder::slotExistingFolderNowBig(const QString &folderPath)
     const auto trailSlashFolderPath = trailingSlashPath(folderPath);
     const auto journal = journalDb();
 
+    // Add the entry to the whitelist if it is neither in the blacklist or whitelist already
+    bool ok1 = false;
+    bool ok2 = false;
+    auto blacklist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok1);
+    auto whitelist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, &ok2);
+    if (ok1 && ok2 && !blacklist.contains(trailSlashFolderPath) && !whitelist.contains(trailSlashFolderPath)) {
+        whitelist.append(trailSlashFolderPath);
+        journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, whitelist);
+    }
+
     auto undecidedListQueryOk = false;
     auto undecidedList = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &undecidedListQueryOk);
     if (undecidedListQueryOk) {
@@ -1295,6 +1305,7 @@ void Folder::slotExistingFolderNowBig(const QString &folderPath)
         existingFolderNowBigActivity._message = tr("Would you like to stop syncing this folder?");
         existingFolderNowBigActivity._accName = _accountState->account()->displayName();
         existingFolderNowBigActivity._folder = alias();
+        existingFolderNowBigActivity._file = cleanPath() + '/' + trailSlashFolderPath;
         existingFolderNowBigActivity._links = {blacklistActivityLink, whitelistActivityLink};
         existingFolderNowBigActivity._id = qHash(existingFolderNowBigActivity._file);
 
index 198731a8b0b62514a05f5020d70b64e9b6cc42bd..efbf46d906f51846b01697393c19f21c3700eebb 100644 (file)
@@ -1266,7 +1266,9 @@ void FolderMan::whitelistFolderPath(const QString &path)
         return;
     }
 
-    folder->whitelistPath(path);
+    const QString folderPath = folder->cleanPath() + QLatin1Char('/');
+    const auto relPath = path.mid(folderPath.length());
+    folder->whitelistPath(relPath);
 }
 
 void FolderMan::blacklistFolderPath(const QString &path)
@@ -1276,7 +1278,9 @@ void FolderMan::blacklistFolderPath(const QString &path)
         return;
     }
 
-    folder->blacklistPath(path);
+    const QString folderPath = folder->cleanPath() + QLatin1Char('/');
+    const auto relPath = path.mid(folderPath.length());
+    folder->blacklistPath(relPath);
 }
 
 QStringList FolderMan::findFileInLocalFolders(const QString &relPath, const AccountPtr acc)
index 03cee25b90f73f59db9733f158582b57b7801fec..a79f1119355c2176a8378161d0f6c2c8d43f952e 100644 (file)
@@ -104,6 +104,7 @@ public:
     /** Returns the folder which the file or directory stored in path is in */
     Folder *folderForPath(const QString &path);
 
+    // Takes local file paths and finds the corresponding folder, adding to correct selective sync list
     void whitelistFolderPath(const QString &path);
     void blacklistFolderPath(const QString &path);
 
index 4dab1d8ae2ef4ccf8cefb397513077720657d101..46aa5ff1fd6bceb5f4e4c87e2c2f422250429da4 100644 (file)
@@ -836,12 +836,14 @@ void ActivityListModel::slotTriggerAction(const int activityIndex, const int act
                (activity._syncFileItemStatus == SyncFileItem::Conflict || activity._syncFileItemStatus == SyncFileItem::FileNameClash)) {
         slotTriggerDefaultAction(activityIndex);
         return;
-    } else if (action._verb == "WHITELIST_FOLDER" && !activity._folder.isEmpty()) {
-        FolderMan::instance()->whitelistFolderPath(activity._folder);
+    } else if (action._verb == "WHITELIST_FOLDER" && !activity._file.isEmpty()) { // _folder == folder alias/name, _file == folder/file path
+        FolderMan::instance()->whitelistFolderPath(activity._file);
         removeActivityFromActivityList(activity);
-    } else if (action._verb == "BLACKLIST_FOLDER" && !activity._folder.isEmpty()) {
-        FolderMan::instance()->blacklistFolderPath(activity._folder);
+        return;
+    } else if (action._verb == "BLACKLIST_FOLDER" && !activity._file.isEmpty()) {
+        FolderMan::instance()->blacklistFolderPath(activity._file);
         removeActivityFromActivityList(activity);
+        return;
     }
 
     emit sendNotificationRequest(activity._accName, action._link, action._verb, activityIndex);