From: Olivier Goffart Date: Mon, 12 Sep 2016 13:02:54 +0000 (+0200) Subject: Revert "FolderWatcher: Act on relative paths #5116 (#5153)" X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b228488eb7a4631da34086b2fd211fe13a6b9be2;p=nextcloud-desktop.git Revert "FolderWatcher: Act on relative paths #5116 (#5153)" This is not sufficient as it is not working for the Socket API. Next commit will fix it in another layer. Also, not ignoring paths that are not inside the folder is wrong as it might still happen if the name has a different casing This reverts commit d5a481f13240b50ff3993184152d3d4145ebfde0. (cherry picked from commit 904cd46f757bf329b719bd815394ff986be99aaf) --- diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 738fe7f11..a4f2e25fa 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -628,6 +628,11 @@ void Folder::removeFromSettings() const settings->remove(FolderMan::escapeAlias(_definition.alias)); } +bool Folder::isFileExcludedAbsolute(const QString& fullPath) const +{ + return _engine->excludedFiles().isExcluded(fullPath, path(), _definition.ignoreHiddenFiles); +} + bool Folder::isFileExcludedRelative(const QString& relativePath) const { return _engine->excludedFiles().isExcluded(path() + relativePath, path(), _definition.ignoreHiddenFiles); diff --git a/src/gui/folder.h b/src/gui/folder.h index bfd4de4d7..79a27ad62 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -183,6 +183,11 @@ public: /// Removes the folder from the account's settings. void removeFromSettings() const; + /** + * Returns whether a file inside this folder should be excluded. + */ + bool isFileExcludedAbsolute(const QString& fullPath) const; + /** * Returns whether a file inside this folder should be excluded. */ diff --git a/src/gui/folderwatcher.cpp b/src/gui/folderwatcher.cpp index c115611bb..30809c82f 100644 --- a/src/gui/folderwatcher.cpp +++ b/src/gui/folderwatcher.cpp @@ -41,9 +41,7 @@ FolderWatcher::FolderWatcher(const QString &root, Folder* folder) : QObject(folder), _folder(folder) { - _canonicalFolderPath = QFileInfo(root).canonicalFilePath(); - - _d.reset(new FolderWatcherPrivate(this, _canonicalFolderPath)); + _d.reset(new FolderWatcherPrivate(this, root)); _timer.start(); } @@ -57,17 +55,10 @@ bool FolderWatcher::pathIsIgnored( const QString& path ) if( !_folder ) return false; #ifndef OWNCLOUD_TEST - QString relPath = path; - if (relPath.startsWith(_canonicalFolderPath)) { - relPath = relPath.remove(0, _canonicalFolderPath.length()+1); - if (_folder->isFileExcludedRelative(relPath)) { - qDebug() << "* Ignoring file" << relPath << "in" << _canonicalFolderPath; - return true; - } + if (_folder->isFileExcludedAbsolute(path)) { + qDebug() << "* Ignoring file" << path; + return true; } - // there could be an odd watch event not being inside the _canonicalFolderPath - // We will just not ignore it then, who knows. - #endif return false; } diff --git a/src/gui/folderwatcher.h b/src/gui/folderwatcher.h index 9b0d17471..15fe223a4 100644 --- a/src/gui/folderwatcher.h +++ b/src/gui/folderwatcher.h @@ -89,7 +89,6 @@ private: QTime _timer; QSet _lastPaths; Folder* _folder; - QString _canonicalFolderPath; friend class FolderWatcherPrivate; };