From c2cb729fee51d9d45888c6fdb781e4a1a7b28edf Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 12 Sep 2016 15:17:21 +0200 Subject: [PATCH] Folder: Cannonicalize the path This is important because we compare the paths from the file system watcher if it starts with this path. Same in the SocketAPI where we need to use cannonical paths in the REGISTER_PATH command, as the plugin themself will do this comparison. Issue #5116 --- src/gui/folder.cpp | 13 +++++++------ src/gui/folder.h | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index f94ba71b4..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); diff --git a/src/gui/folder.h b/src/gui/folder.h index 40ff6deb1..f5967c9b6 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -288,6 +288,7 @@ private: AccountStatePtr _accountState; FolderDefinition _definition; + QString _canonicalLocalPath; // As returned with QFileInfo:canonicalFilePath. Always ends with "/" SyncResult _syncResult; QScopedPointer _engine;