From 859bf078733fc7d4688b437ab2c25dd59bb73a41 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 18 Aug 2023 17:04:11 +0800 Subject: [PATCH] Notify when new lock files are found in folderwatcher Signed-off-by: Claudio Cambra --- src/gui/folderwatcher.cpp | 15 ++++++++++----- src/gui/folderwatcher.h | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) 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. * -- 2.30.2