From: Claudio Cambra Date: Fri, 18 Aug 2023 09:02:16 +0000 (+0800) Subject: Do not search for matching file pattern in possiblyAddUnlockedFilePath X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~9^2~19^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f5d15d8a8251f1ecf37972ba3bebd56b74060b3f;p=nextcloud-desktop.git Do not search for matching file pattern in possiblyAddUnlockedFilePath Signed-off-by: Claudio Cambra --- diff --git a/src/gui/folderwatcher.cpp b/src/gui/folderwatcher.cpp index 74f716a7c..3e93fa674 100644 --- a/src/gui/folderwatcher.cpp +++ b/src/gui/folderwatcher.cpp @@ -203,9 +203,13 @@ void FolderWatcher::changeDetected(const QStringList &paths) && Utility::fileNamesEqual(path, _testNotificationPath)) { _testNotificationPath.clear(); } - - const auto checkResult = checkIfFileIsLockOrUnlock(path); + + 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); } @@ -250,16 +254,15 @@ void FolderWatcher::folderAccountCapabilitiesChanged() _shouldWatchForFileUnlocking = _folder->accountState()->account()->capabilities().filesLockAvailable(); } -FolderWatcher::FileLockingInfo FolderWatcher::checkIfFileIsLockOrUnlock(const QString &path) const +FolderWatcher::FileLockingInfo FolderWatcher::checkIfFileIsLockOrUnlock(const QString &path, const QString &lockFileNamePattern) const { FileLockingInfo result; - const auto lockFilePatternFound = filePathLockFilePatternMatch(path); - if (lockFilePatternFound.isEmpty()) { + if (lockFileNamePattern.isEmpty()) { return result; } - const auto lockFilePathWithoutPrefix = QString(path).replace(lockFilePatternFound, QStringLiteral("")); + const auto lockFilePathWithoutPrefix = QString(path).replace(lockFileNamePattern, QStringLiteral("")); auto lockFilePathWithoutPrefixSplit = lockFilePathWithoutPrefix.split(QLatin1Char('.')); if (lockFilePathWithoutPrefixSplit.size() < 2) { diff --git a/src/gui/folderwatcher.h b/src/gui/folderwatcher.h index f2d59f703..41fd86ee1 100644 --- a/src/gui/folderwatcher.h +++ b/src/gui/folderwatcher.h @@ -141,7 +141,7 @@ private: void appendSubPaths(QDir dir, QStringList& subPaths); - [[nodiscard]] FileLockingInfo checkIfFileIsLockOrUnlock(const QString &path) const; + [[nodiscard]] FileLockingInfo checkIfFileIsLockOrUnlock(const QString &path, const QString &lockFileNamePattern) const; [[nodiscard]] QString findMatchingUnlockedFileInDir(const QString &dirPath, const QString &lockFileName) const; /* Check if the path should be igored by the FolderWatcher. */