Skip to content

Commit

Permalink
Default to adding existing now big folders to whitelist when undecided
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Jul 5, 2023
1 parent c963efa commit 062960f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,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) {
Expand Down Expand Up @@ -1261,6 +1271,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);

Expand Down
8 changes: 6 additions & 2 deletions src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/gui/folderman.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class FolderMan : public QObject
/** 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);

Expand Down
10 changes: 6 additions & 4 deletions src/gui/tray/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,12 +785,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);
Expand Down

0 comments on commit 062960f

Please sign in to comment.