Skip to content

Commit

Permalink
Deduplicate whitelistFolderPath and blacklistFolderPath
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Aug 3, 2023
1 parent b0d4307 commit 5dfce26
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ Folder *FolderMan::folderForPath(const QString &path)
return it != folders.cend() ? *it : nullptr;
}

void FolderMan::whitelistFolderPath(const QString &path)
void FolderMan::addFolderToSelectiveSyncList(const QString &path, const SyncJournalDb::SelectiveSyncListType list)
{
const auto folder = folderForPath(path);
if (!folder) {
Expand All @@ -1268,19 +1268,27 @@ void FolderMan::whitelistFolderPath(const QString &path)

const QString folderPath = folder->cleanPath() + QLatin1Char('/');
const auto relPath = path.mid(folderPath.length());
folder->whitelistPath(relPath);

switch (list) {
case SyncJournalDb::SelectiveSyncListType::SelectiveSyncWhiteList:
folder->whitelistPath(relPath);
break;
case SyncJournalDb::SelectiveSyncListType::SelectiveSyncBlackList:
folder->blacklistPath(relPath);
break;
default:
Q_UNREACHABLE();
}
}

void FolderMan::blacklistFolderPath(const QString &path)
void FolderMan::whitelistFolderPath(const QString &path)
{
const auto folder = folderForPath(path);
if (!folder) {
return;
}
addFolderToSelectiveSyncList(path, SyncJournalDb::SelectiveSyncListType::SelectiveSyncWhiteList);
}

const QString folderPath = folder->cleanPath() + QLatin1Char('/');
const auto relPath = path.mid(folderPath.length());
folder->blacklistPath(relPath);
void FolderMan::blacklistFolderPath(const QString &path)
{
addFolderToSelectiveSyncList(path, SyncJournalDb::SelectiveSyncListType::SelectiveSyncBlackList);
}

QStringList FolderMan::findFileInLocalFolders(const QString &relPath, const AccountPtr acc)
Expand Down
2 changes: 2 additions & 0 deletions src/gui/folderman.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ private slots:

[[nodiscard]] bool isSwitchToVfsNeeded(const FolderDefinition &folderDefinition) const;

void addFolderToSelectiveSyncList(const QString &path, const SyncJournalDb::SelectiveSyncListType list);

QSet<Folder *> _disabledFolders;
Folder::Map _folderMap;
QString _folderConfigPath;
Expand Down

0 comments on commit 5dfce26

Please sign in to comment.