From: Claudio Cambra Date: Fri, 18 Aug 2023 09:04:11 +0000 (+0800) Subject: Notify when new lock files are found in folderwatcher X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~9^2~19^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=859bf078733fc7d4688b437ab2c25dd59bb73a41;p=nextcloud-desktop.git Notify when new lock files are found in folderwatcher Signed-off-by: Claudio Cambra --- diff --git a/src/gui/folderwatcher.cpp b/src/gui/folderwatcher.cpp index 3e93fa674..f971b7139 100644 --- a/src/gui/folderwatcher.cpp +++ b/src/gui/folderwatcher.cpp @@ -197,6 +197,7 @@ void FolderWatcher::changeDetected(const QStringList &paths) QSet changedPaths; QSet unlockedFiles; QSet lockedFiles; + QSet lockFiles; for (const auto &path : paths) { if (!_testNotificationPath.isEmpty() @@ -207,14 +208,11 @@ void FolderWatcher::changeDetected(const QStringList &paths) const auto lockFileNamePattern = filePathLockFilePatternMatch(path); const auto checkResult = checkIfFileIsLockOrUnlock(path,lockFileNamePattern); if (_shouldWatchForFileUnlocking) { - const auto lockFileNamePattern = filePathLockFilePatternMatch(path); - const auto unlockedFilePath = checkIfFileIsLockOrUnlock(path, lockFileNamePattern); - if (checkResult.type == FileLockingInfo::Type::Unlocked && !checkResult.path.isEmpty()) { unlockedFiles.insert(checkResult.path); + } else if (!lockFileNamePattern.isEmpty()) { + lockFiles.insert(path); } - - qCDebug(lcFolderWatcher) << "Unlocked files:" << unlockedFiles.values(); } if (checkResult.type == FileLockingInfo::Type::Locked && !checkResult.path.isEmpty()) { @@ -231,6 +229,9 @@ void FolderWatcher::changeDetected(const QStringList &paths) changedPaths.insert(path); } + qCDebug(lcFolderWatcher) << "Unlocked files:" << unlockedFiles.values(); + qCDebug(lcFolderWatcher) << "Lock files:" << lockFiles; + if (!unlockedFiles.isEmpty()) { emit filesLockReleased(unlockedFiles); } @@ -239,6 +240,10 @@ void FolderWatcher::changeDetected(const QStringList &paths) emit filesLockImposed(lockedFiles); } + if (!lockFiles.isEmpty()) { + emit lockFilesFound(lockFiles); + } + if (changedPaths.isEmpty()) { return; } diff --git a/src/gui/folderwatcher.h b/src/gui/folderwatcher.h index 41fd86ee1..0cfd0bd80 100644 --- a/src/gui/folderwatcher.h +++ b/src/gui/folderwatcher.h @@ -102,6 +102,8 @@ signals: */ void filesLockImposed(const QSet &files); + void lockFilesFound(const QSet &files); + /** * Emitted if some notifications were lost. *