QSet<QString> changedPaths;
QSet<QString> unlockedFiles;
QSet<QString> lockedFiles;
- QSet<QString> lockFiles;
for (const auto &path : paths) {
if (!_testNotificationPath.isEmpty()
}
const auto lockFileNamePattern = filePathLockFilePatternMatch(path);
- const auto checkResult = checkIfFileIsLockOrUnlock(path,lockFileNamePattern);
+ const auto checkResult = lockFileTargetFilePath(path,lockFileNamePattern);
if (_shouldWatchForFileUnlocking) {
- if (checkResult.type == FileLockingInfo::Type::Unlocked && !checkResult.path.isEmpty()) {
+ // Lock file has been deleted, file now unlocked
+ if (checkResult.type == FileLockingInfo::Type::Unlocked && !checkResult.path.isEmpty() && !QFile::exists(path)) {
unlockedFiles.insert(checkResult.path);
- } else if (!lockFileNamePattern.isEmpty()) {
- lockFiles.insert(path);
+ } else if (!checkResult.path.isEmpty() && QFile::exists(path)) { // Lock file found
+ lockedFiles.insert(checkResult.path);
}
}
}
qCDebug(lcFolderWatcher) << "Unlocked files:" << unlockedFiles.values();
- qCDebug(lcFolderWatcher) << "Lock files:" << lockFiles;
+ qCDebug(lcFolderWatcher) << "Locked files:" << lockedFiles;
if (!unlockedFiles.isEmpty()) {
emit filesLockReleased(unlockedFiles);
emit filesLockImposed(lockedFiles);
}
- if (!lockFiles.isEmpty()) {
- emit lockFilesFound(lockFiles);
+ if (!lockedFiles.isEmpty()) {
+ emit lockedFilesFound(lockedFiles);
}
if (changedPaths.isEmpty()) {
_shouldWatchForFileUnlocking = _folder->accountState()->account()->capabilities().filesLockAvailable();
}
-FolderWatcher::FileLockingInfo FolderWatcher::checkIfFileIsLockOrUnlock(const QString &path, const QString &lockFileNamePattern) const
+FolderWatcher::FileLockingInfo FolderWatcher::lockFileTargetFilePath(const QString &path, const QString &lockFileNamePattern) const
{
FileLockingInfo result;
void lockFilesFound(const QSet<QString> &files);
+ void lockedFilesFound(const QSet<QString> &files);
+
/**
* Emitted if some notifications were lost.
*
void appendSubPaths(QDir dir, QStringList& subPaths);
- [[nodiscard]] FileLockingInfo checkIfFileIsLockOrUnlock(const QString &path, const QString &lockFileNamePattern) const;
+ [[nodiscard]] FileLockingInfo lockFileTargetFilePath(const QString &path, const QString &lockFileNamePattern) const;
[[nodiscard]] QString findMatchingUnlockedFileInDir(const QString &dirPath, const QString &lockFileName) const;
+ QString findMatchingUnlockedFileInDir(const QString &dirPath, const QString &lockFileName);
+
/* Check if the path should be igored by the FolderWatcher. */
[[nodiscard]] bool pathIsIgnored(const QString &path) const;