Notify when new lock files are found in folderwatcher

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-08-18 17:04:11 +08:00 committed by Matthieu Gallien
parent f5d15d8a82
commit 859bf07873
No known key found for this signature in database
GPG Key ID: 7D0F74F05C22F553
2 changed files with 12 additions and 5 deletions

View File

@ -197,6 +197,7 @@ void FolderWatcher::changeDetected(const QStringList &paths)
QSet<QString> changedPaths;
QSet<QString> unlockedFiles;
QSet<QString> lockedFiles;
QSet<QString> 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;
}

View File

@ -102,6 +102,8 @@ signals:
*/
void filesLockImposed(const QSet<QString> &files);
void lockFilesFound(const QSet<QString> &files);
/**
* Emitted if some notifications were lost.
*