Skip to content

Commit c4b636a

Browse files
committed
chore: only ignore locked files not already ignored
fix behavior to match expectations from existing automated tests Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
1 parent ce16030 commit c4b636a

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/csync/csync_exclude.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum CSYNC_EXCLUDE_TYPE {
3737
CSYNC_FILE_EXCLUDE_SERVER_BLACKLISTED,
3838
CSYNC_FILE_EXCLUDE_LEADING_SPACE,
3939
CSYNC_FILE_EXCLUDE_LEADING_AND_TRAILING_SPACE,
40+
CSYNC_FILE_LOCKED_SILENTLY_EXCLUDED,
4041
};
4142

4243
class ExcludedFilesTest;

src/libsync/discovery.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,6 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
259259

260260
auto excluded = _discoveryData->_excludes->traversalPatternMatch(path, isDirectory ? ItemTypeDirectory : ItemTypeFile);
261261

262-
if (OCC::FileSystem::isFileLocked(_discoveryData->_localDir + path, OCC::FileSystem::LockMode::SharedRead)) {
263-
qCInfo(lcDisco) << _discoveryData->_localDir + path << "is locked" << "exluding it from sync";
264-
excluded = CSYNC_FILE_SILENTLY_EXCLUDED;
265-
266-
emit _discoveryData->seenLockedFile(path);
267-
}
268-
269262
const auto fileName = path.mid(path.lastIndexOf('/') + 1);
270263

271264
const auto isLocal = entries.localEntry.isValid();
@@ -361,6 +354,13 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
361354
}
362355
}
363356

357+
if (excluded == CSYNC_NOT_EXCLUDED && OCC::FileSystem::isFileLocked(_discoveryData->_localDir + path, OCC::FileSystem::LockMode::SharedRead)) {
358+
qCInfo(lcDisco) << _discoveryData->_localDir + path << "is locked" << "exluding it from sync";
359+
excluded = CSYNC_FILE_LOCKED_SILENTLY_EXCLUDED;
360+
361+
emit _discoveryData->seenLockedFile(_discoveryData->_localDir + path);
362+
}
363+
364364
if (excluded == CSYNC_NOT_EXCLUDED && !entries.localEntry.isSymLink) {
365365
return false;
366366
} else if (excluded == CSYNC_FILE_SILENTLY_EXCLUDED || excluded == CSYNC_FILE_EXCLUDE_AND_REMOVE) {
@@ -391,6 +391,9 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
391391
case CSYNC_FILE_EXCLUDE_AND_REMOVE:
392392
qCFatal(lcDisco) << "These were handled earlier";
393393
break;
394+
case CSYNC_FILE_LOCKED_SILENTLY_EXCLUDED:
395+
item->_errorString = tr("File is locked exluding it from sync.");
396+
break;
394397
case CSYNC_FILE_EXCLUDE_LIST:
395398
item->_errorString = tr("File is listed on the ignore list.");
396399
break;
@@ -2463,6 +2466,7 @@ bool ProcessDirectoryJob::maybeRenameForWindowsCompatibility(const QString &abso
24632466
switch (excludeReason)
24642467
{
24652468
case CSYNC_NOT_EXCLUDED:
2469+
case CSYNC_FILE_LOCKED_SILENTLY_EXCLUDED:
24662470
case CSYNC_FILE_EXCLUDE_CASE_CLASH_CONFLICT:
24672471
case CSYNC_FILE_EXCLUDE_AND_REMOVE:
24682472
case CSYNC_FILE_EXCLUDE_CANNOT_ENCODE:

0 commit comments

Comments
 (0)