From 51a2e6c5800526e99814a28138e882d373a677bb Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 13 Oct 2015 12:53:38 +0200 Subject: [PATCH] Exclusion: Fix confusion with relative and absolute paths --- src/gui/folder.cpp | 7 ++++++- src/gui/folder.h | 7 ++++++- src/gui/folderstatusmodel.cpp | 5 ++--- src/gui/folderwatcher.cpp | 2 +- src/gui/selectivesyncdialog.cpp | 5 +++-- src/gui/socketapi.cpp | 2 +- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 6aad7011c..1547469db 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -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 diff --git a/src/gui/folder.h b/src/gui/folder.h index bbead3db4..2734603ba 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -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(); diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index db8b67f28..bcbbdcd98 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -514,10 +514,9 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_) QMutableListIterator 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); } } diff --git a/src/gui/folderwatcher.cpp b/src/gui/folderwatcher.cpp index 217ebd106..30809c82f 100644 --- a/src/gui/folderwatcher.cpp +++ b/src/gui/folderwatcher.cpp @@ -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; } diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp index f24e42f0c..021e00579 100644 --- a/src/gui/selectivesyncdialog.cpp +++ b/src/gui/selectivesyncdialog.cpp @@ -185,7 +185,9 @@ void SelectiveSyncTreeView::slotUpdateDirectories(QStringList list) QMutableListIterator 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; } diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index ea2115575..e145f8129 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -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); } -- 2.30.2