Merge pull request #3882 from nextcloud/bugfix/sync-exclude

Add .sync-exclude.lst to exclude files
This commit is contained in:
Matthieu Gallien 2021-10-14 21:52:27 +02:00 committed by GitHub
commit 7206d626ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -232,18 +232,16 @@ ExcludedFiles::ExcludedFiles(const QString &localPath)
// We're in a detached exclude probably coming from a partial sync or test // We're in a detached exclude probably coming from a partial sync or test
if (_localPath.isEmpty()) if (_localPath.isEmpty())
return; return;
// Load exclude file from base dir
QFileInfo fi(_localPath + QStringLiteral(".sync-exclude.lst"));
if (fi.isReadable())
addInTreeExcludeFilePath(fi.absoluteFilePath());
} }
ExcludedFiles::~ExcludedFiles() = default; ExcludedFiles::~ExcludedFiles() = default;
void ExcludedFiles::addExcludeFilePath(const QString &path) 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) void ExcludedFiles::addInTreeExcludeFilePath(const QString &path)

View file

@ -544,6 +544,11 @@ void SyncEngine::startSync()
_discoveryPhase.reset(new DiscoveryPhase); _discoveryPhase.reset(new DiscoveryPhase);
_discoveryPhase->_account = _account; _discoveryPhase->_account = _account;
_discoveryPhase->_excludes = _excludedFiles.data(); _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->_statedb = _journal;
_discoveryPhase->_localDir = _localPath; _discoveryPhase->_localDir = _localPath;
if (!_discoveryPhase->_localDir.endsWith('/')) if (!_discoveryPhase->_localDir.endsWith('/'))