Exclusion: Fix confusion with relative and absolute paths
authorChristian Kamm <mail@ckamm.de>
Tue, 13 Oct 2015 10:53:38 +0000 (12:53 +0200)
committerChristian Kamm <mail@ckamm.de>
Tue, 13 Oct 2015 10:53:38 +0000 (12:53 +0200)
src/gui/folder.cpp
src/gui/folder.h
src/gui/folderstatusmodel.cpp
src/gui/folderwatcher.cpp
src/gui/selectivesyncdialog.cpp
src/gui/socketapi.cpp

index 6aad7011cee3b8f1d669a44aac1a7845e44d3c43..1547469db1eccd284aaf5c96b69bcb8b054a6176 100644 (file)
@@ -707,7 +707,7 @@ void Folder::removeFromSettings() const
     settings->remove(_definition.alias);
 }
 
-bool Folder::isFileExcluded(const QString& fullPath) const
+bool Folder::isFileExcludedAbsolute(const QString& fullPath) const
 {
     QString myFullPath = fullPath;
     if (myFullPath.endsWith(QLatin1Char('/'))) {
@@ -724,6 +724,11 @@ bool Folder::isFileExcluded(const QString& fullPath) const
     return excl != CSYNC_NOT_EXCLUDED;
 }
 
+bool Folder::isFileExcludedRelative(const QString& relativePath) const
+{
+    return isFileExcludedAbsolute(path() + relativePath);
+}
+
 void Folder::watcherSlot(QString fn)
 {
     // FIXME: On OS X we could not do this "if" since on OS X the file watcher ignores events for ourselves
index bbead3db49fa4021c12baf64fd69f805d91a86c4..2734603ba74e1440846352ce99577b5fbba0b5c4 100644 (file)
@@ -200,7 +200,12 @@ public:
      /**
       * Returns whether a file inside this folder should be excluded.
       */
-     bool isFileExcluded(const QString& fullPath) const;
+     bool isFileExcludedAbsolute(const QString& fullPath) const;
+
+     /**
+      * Returns whether a file inside this folder should be excluded.
+      */
+     bool isFileExcludedRelative(const QString& relativePath) const;
 
 signals:
     void syncStateChange();
index db8b67f28b9dfddadf82643ae8c04c0023c06019..bcbbdcd98c5b7c4d18011682245bf34aa470ccf9 100644 (file)
@@ -514,10 +514,9 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
     QMutableListIterator<QString> it(list);
     while (it.hasNext()) {
         it.next();
-        if (parentInfo->_folder->isFileExcluded(it.value())) {
+        it.value().remove(pathToRemove);
+        if (parentInfo->_folder->isFileExcludedRelative(it.value())) {
             it.remove();
-        } else {
-            it.value().remove(pathToRemove);
         }
     }
 
index 217ebd106e2b95a94a3f351b35950aea2772767c..30809c82f59d323c0d800988c03fe08042f019c6 100644 (file)
@@ -55,7 +55,7 @@ bool FolderWatcher::pathIsIgnored( const QString& path )
     if( !_folder ) return false;
 
 #ifndef OWNCLOUD_TEST
-    if (_folder->isFileExcluded(path)) {
+    if (_folder->isFileExcludedAbsolute(path)) {
         qDebug() << "* Ignoring file" << path;
         return true;
     }
index f24e42f0cf8fb5dd8b32ab48a54eda550c5331f6..021e00579a240d0538a2393e0c2409f4f8e69247 100644 (file)
@@ -185,7 +185,9 @@ void SelectiveSyncTreeView::slotUpdateDirectories(QStringList list)
     QMutableListIterator<QString> it(list);
     while (it.hasNext()) {
         it.next();
-        if (f.isFileExcluded(it.value())) {
+        QString path = it.value();
+        path.remove(pathToRemove);
+        if (f.isFileExcludedRelative(path)) {
             it.remove();
         }
     }
@@ -195,7 +197,6 @@ void SelectiveSyncTreeView::slotUpdateDirectories(QStringList list)
     if (_oldBlackList == QStringList("/")) {
         _oldBlackList.clear();
         foreach (QString path, list) {
-            path.remove(pathToRemove);
             if (path.isEmpty()) {
                 continue;
             }
index ea2115575b2b248f0fdb134698b2f6ec112c4b4f..e145f81295e2b57907b8dca6a1762d7ccccd5510 100644 (file)
@@ -540,7 +540,7 @@ SyncFileStatus SocketApi::fileStatus(Folder *folder, const QString& systemFileNa
     }
 
     // Is it excluded?
-    if( folder->isFileExcluded(file) ) {
+    if( folder->isFileExcludedAbsolute(file) ) {
         return SyncFileStatus(SyncFileStatus::STATUS_IGNORE);
     }