Selective sync: When applying selective sync, put new folder that were just checked...
authorOlivier Goffart <ogoffart@woboq.com>
Fri, 7 Aug 2015 11:36:10 +0000 (13:36 +0200)
committerOlivier Goffart <ogoffart@woboq.com>
Fri, 7 Aug 2015 11:37:52 +0000 (13:37 +0200)
Issue #3560

Otherwise the just checked folder will be chacked again for their size.
We do not want that.

src/gui/folderstatusmodel.cpp

index 9c32c7dea7f4ef1c63be9b33390d15fddb2eb12a..4943c602c0879cd3e720d5a337e20f3e90c7ae98 100644 (file)
@@ -566,13 +566,14 @@ void FolderStatusModel::slotApplySelectiveSync()
         QStringList blackList = createBlackList(&_folders[i], oldBlackList);
         folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blackList);
 
-        // The folders that were undecided should be part of the white list if they are not in the blacklist
-        QStringList toAddToWhiteList;
-        foreach (const auto &undec, folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList)) {
-            if (!blackList.contains(undec)) {
-                toAddToWhiteList.append(undec);
-            }
-        }
+        auto blackListSet = blackList.toSet();
+        auto oldBlackListSet = oldBlackList.toSet();
+
+        // The folders that were undecided or blacklisted and that are now checked should go on the white list.
+        // The user confirmed them already just now.
+        QStringList toAddToWhiteList = ((oldBlackListSet + folder->journalDb()->getSelectiveSyncList(
+                SyncJournalDb::SelectiveSyncUndecidedList).toSet()) - blackListSet).toList();
+
         if (!toAddToWhiteList.isEmpty()) {
             auto whiteList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList);
             whiteList += toAddToWhiteList;
@@ -582,8 +583,6 @@ void FolderStatusModel::slotApplySelectiveSync()
         folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, QStringList());
 
         // do the sync if there was changes
-        auto blackListSet = blackList.toSet();
-        auto oldBlackListSet = oldBlackList.toSet();
         auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet);
         if (!changes.isEmpty()) {
             if (folder->isBusy()) {