From: Claudio Cambra Date: Wed, 5 Jul 2023 18:47:05 +0000 (+0800) Subject: Default to adding existing now big folders to whitelist when undecided X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~92^2^2~57^2~22 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a93279bcbf0cc637313f0c85fef54e0d2788a20e;p=nextcloud-desktop.git Default to adding existing now big folders to whitelist when undecided Signed-off-by: Claudio Cambra --- diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index d40017dec..934acd751 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -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); diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 198731a8b..efbf46d90 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -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) diff --git a/src/gui/folderman.h b/src/gui/folderman.h index 03cee25b9..a79f11193 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -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); diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index 4dab1d8ae..46aa5ff1f 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -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);