@@ -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,14 @@ 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+ (!entries.dbEntry .isValid () || !entries.serverEntry .isValid () || entries.serverEntry .etag == entries.dbEntry ._etag )) {
359+ qCInfo (lcDisco) << _discoveryData->_localDir + path << " is locked" << " exluding it from sync" ;
360+ excluded = CSYNC_FILE_LOCKED_SILENTLY_EXCLUDED;
361+
362+ emit _discoveryData->seenLockedFile (_discoveryData->_localDir + path);
363+ }
364+
364365 if (excluded == CSYNC_NOT_EXCLUDED && !entries.localEntry .isSymLink ) {
365366 return false ;
366367 } else if (excluded == CSYNC_FILE_SILENTLY_EXCLUDED || excluded == CSYNC_FILE_EXCLUDE_AND_REMOVE) {
@@ -391,6 +392,9 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
391392 case CSYNC_FILE_EXCLUDE_AND_REMOVE:
392393 qCFatal (lcDisco) << " These were handled earlier" ;
393394 break ;
395+ case CSYNC_FILE_LOCKED_SILENTLY_EXCLUDED:
396+ item->_errorString = tr (" File is locked by another application." );
397+ break ;
394398 case CSYNC_FILE_EXCLUDE_LIST:
395399 item->_errorString = tr (" File is listed on the ignore list." );
396400 break ;
@@ -2463,6 +2467,7 @@ bool ProcessDirectoryJob::maybeRenameForWindowsCompatibility(const QString &abso
24632467 switch (excludeReason)
24642468 {
24652469 case CSYNC_NOT_EXCLUDED:
2470+ case CSYNC_FILE_LOCKED_SILENTLY_EXCLUDED:
24662471 case CSYNC_FILE_EXCLUDE_CASE_CLASH_CONFLICT:
24672472 case CSYNC_FILE_EXCLUDE_AND_REMOVE:
24682473 case CSYNC_FILE_EXCLUDE_CANNOT_ENCODE:
0 commit comments