]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Add .sync-exclude.lst to exclude files
authorFelix Weilbach <felix.weilbach@nextcloud.com>
Mon, 11 Oct 2021 12:27:05 +0000 (14:27 +0200)
committerMatthieu Gallien (Rebase PR Action) <matthieu_gallien@yahoo.fr>
Thu, 14 Oct 2021 14:02:29 +0000 (14:02 +0000)
Previously the .sync-exclude.lst file of the sync root directory was
not added to the exclude files, because the current logic did only
recognize .sync-exclude.lst files when their containing directory was
discovered during the discovery phase. Therefore the sync root
.sync-exclude.lst file was never discovered. See also
ExcludedFiles::traversalPatternMatch().

Fix: #3830, #2728

Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
src/csync/csync_exclude.cpp
src/libsync/syncengine.cpp

index 10f0b238acac388dec1a7ac9e61028ba0c164f9e..c15fc5e017efe1b41944331b3f27802ff94c0284 100644 (file)
@@ -232,18 +232,16 @@ ExcludedFiles::ExcludedFiles(const QString &localPath)
     // We're in a detached exclude probably coming from a partial sync or test
     if (_localPath.isEmpty())
         return;
-
-    // Load exclude file from base dir
-    QFileInfo fi(_localPath + QStringLiteral(".sync-exclude.lst"));
-    if (fi.isReadable())
-        addInTreeExcludeFilePath(fi.absoluteFilePath());
 }
 
 ExcludedFiles::~ExcludedFiles() = default;
 
 void ExcludedFiles::addExcludeFilePath(const QString &path)
 {
-    _excludeFiles[_localPath].append(path);
+    auto &excludeFilesLocalPath = _excludeFiles[_localPath];
+    if (std::find(excludeFilesLocalPath.cbegin(), excludeFilesLocalPath.cend(), path) == excludeFilesLocalPath.cend()) {
+        excludeFilesLocalPath.append(path);
+    }
 }
 
 void ExcludedFiles::addInTreeExcludeFilePath(const QString &path)
index e9f919f57eb318d9ed4c33dc65ba6d5abf9c0148..6cd745aef449dd6051983b86b1edef098278a91c 100644 (file)
@@ -544,6 +544,11 @@ void SyncEngine::startSync()
     _discoveryPhase.reset(new DiscoveryPhase);
     _discoveryPhase->_account = _account;
     _discoveryPhase->_excludes = _excludedFiles.data();
+    const QString excludeFilePath = _localPath + QStringLiteral(".sync-exclude.lst");
+    if (QFile::exists(excludeFilePath)) {
+        _discoveryPhase->_excludes->addExcludeFilePath(excludeFilePath);
+        _discoveryPhase->_excludes->reloadExcludeFiles();
+    }
     _discoveryPhase->_statedb = _journal;
     _discoveryPhase->_localDir = _localPath;
     if (!_discoveryPhase->_localDir.endsWith('/'))