Add methods to Folder so that other classes can easily add folder paths to white/blacklists

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-07-05 17:16:03 +08:00
parent 993ee6cb5b
commit 2bcefd6105
No known key found for this signature in database
GPG key ID: C839200C384636B0
2 changed files with 29 additions and 0 deletions

View file

@ -13,6 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "common/syncjournaldb.h"
#include "config.h"
#include "account.h"
@ -842,6 +843,29 @@ bool Folder::pathIsIgnored(const QString &path) const
return false;
}
void Folder::appendPathToSelectiveSyncList(const QString &path, const SyncJournalDb::SelectiveSyncListType listType)
{
const auto folderPath = trailingSlashPath(path);
const auto journal = journalDb();
auto ok = false;
auto list = journal->getSelectiveSyncList(listType, &ok);
if (ok) {
list.append(folderPath);
journal->setSelectiveSyncList(listType, list);
}
}
void Folder::whitelistPath(const QString &path)
{
appendPathToSelectiveSyncList(path, SyncJournalDb::SelectiveSyncWhiteList);
}
void Folder::blacklistPath(const QString &path)
{
appendPathToSelectiveSyncList(path, SyncJournalDb::SelectiveSyncBlackList);
}
bool Folder::isFileExcludedAbsolute(const QString &fullPath) const
{
return _engine->excludedFiles().isExcluded(fullPath, path(), _definition.ignoreHiddenFiles);

View file

@ -301,6 +301,9 @@ public:
QString fileFromLocalPath(const QString &localPath) const;
void whitelistPath(const QString &path);
void blacklistPath(const QString &path);
signals:
void syncStateChange();
void syncStarted();
@ -468,6 +471,8 @@ private:
void correctPlaceholderFiles();
void appendPathToSelectiveSyncList(const QString &path, const SyncJournalDb::SelectiveSyncListType listType);
AccountStatePtr _accountState;
FolderDefinition _definition;
QString _canonicalLocalPath; // As returned with QFileInfo:canonicalFilePath. Always ends with "/"