]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
FolderWatcher: Act on relative paths #5116 (#5153)
authorMarkus Goetz <markus@woboq.com>
Mon, 12 Sep 2016 12:03:11 +0000 (14:03 +0200)
committerChristian Kamm <mail@ckamm.de>
Mon, 12 Sep 2016 12:09:13 +0000 (14:09 +0200)
(cherry picked from commit d5a481f13240b50ff3993184152d3d4145ebfde0)

src/gui/folder.cpp
src/gui/folder.h
src/gui/folderwatcher.cpp
src/gui/folderwatcher.h

index a4f2e25fac0a6a517541346d1b08f5fbf6ba3711..738fe7f11b61e626a65971d393e67c52c787eb79 100644 (file)
@@ -628,11 +628,6 @@ 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);
index 79a27ad623e1f1cdd9040e85031bbce939c9d301..bfd4de4d7b775580fd6450e3ebf88e02e9d9ae52 100644 (file)
@@ -183,11 +183,6 @@ 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.
       */
index 30809c82f59d323c0d800988c03fe08042f019c6..c115611bb203fbaa5ecdde064a7996cbd0874b9d 100644 (file)
@@ -41,7 +41,9 @@ FolderWatcher::FolderWatcher(const QString &root, Folder* folder)
     : QObject(folder),
       _folder(folder)
 {
-    _d.reset(new FolderWatcherPrivate(this, root));
+    _canonicalFolderPath = QFileInfo(root).canonicalFilePath();
+
+    _d.reset(new FolderWatcherPrivate(this, _canonicalFolderPath));
 
     _timer.start();
 }
@@ -55,10 +57,17 @@ bool FolderWatcher::pathIsIgnored( const QString& path )
     if( !_folder ) return false;
 
 #ifndef OWNCLOUD_TEST
-    if (_folder->isFileExcludedAbsolute(path)) {
-        qDebug() << "* Ignoring file" << path;
-        return true;
+    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;
+        }
     }
+    // there could be an odd watch event not being inside the _canonicalFolderPath
+    // We will just not ignore it then, who knows.
+
 #endif
     return false;
 }
index 15fe223a4410278d215cd6b563e8dabcc1a7eb66..9b0d17471856109bd4baa073ece8535d309244ff 100644 (file)
@@ -89,6 +89,7 @@ private:
     QTime _timer;
     QSet<QString> _lastPaths;
     Folder* _folder;
+    QString _canonicalFolderPath;
 
     friend class FolderWatcherPrivate;
 };