diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 532c38de5..b1112e13a 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -124,6 +124,11 @@ void Folder::checkLocalPath() { const QFileInfo fi(_definition.localPath); + _canonicalLocalPath = fi.canonicalFilePath(); + if( !_canonicalLocalPath.endsWith('/') ) { + _canonicalLocalPath.append('/'); + } + if( fi.isDir() && fi.isReadable() ) { qDebug() << "Checked local path ok"; } else { @@ -161,11 +166,7 @@ QString Folder::alias() const QString Folder::path() const { - QString p(_definition.localPath); - if( ! p.endsWith('/') ) { - p.append('/'); - } - return p; + return _canonicalLocalPath; } QString Folder::shortGuiLocalPath() const @@ -198,7 +199,7 @@ void Folder::setIgnoreHiddenFiles(bool ignore) QString Folder::cleanPath() { - QString cleanedPath = QDir::cleanPath(_definition.localPath); + QString cleanedPath = QDir::cleanPath(_canonicalLocalPath); if(cleanedPath.length() == 3 && cleanedPath.endsWith(":/")) cleanedPath.remove(2,1); @@ -621,6 +622,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 762ea52b1..f5967c9b6 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -184,6 +184,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. */ @@ -283,6 +288,7 @@ private: AccountStatePtr _accountState; FolderDefinition _definition; + QString _canonicalLocalPath; // As returned with QFileInfo:canonicalFilePath. Always ends with "/" SyncResult _syncResult; QScopedPointer _engine; 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; };