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
This commit is contained in:
Olivier Goffart 2016-09-12 15:17:21 +02:00
parent 904cd46f75
commit c2cb729fee
2 changed files with 8 additions and 6 deletions

View file

@ -124,6 +124,11 @@ void Folder::checkLocalPath()
{ {
const QFileInfo fi(_definition.localPath); const QFileInfo fi(_definition.localPath);
_canonicalLocalPath = fi.canonicalFilePath();
if( !_canonicalLocalPath.endsWith('/') ) {
_canonicalLocalPath.append('/');
}
if( fi.isDir() && fi.isReadable() ) { if( fi.isDir() && fi.isReadable() ) {
qDebug() << "Checked local path ok"; qDebug() << "Checked local path ok";
} else { } else {
@ -161,11 +166,7 @@ QString Folder::alias() const
QString Folder::path() const QString Folder::path() const
{ {
QString p(_definition.localPath); return _canonicalLocalPath;
if( ! p.endsWith('/') ) {
p.append('/');
}
return p;
} }
QString Folder::shortGuiLocalPath() const QString Folder::shortGuiLocalPath() const
@ -198,7 +199,7 @@ void Folder::setIgnoreHiddenFiles(bool ignore)
QString Folder::cleanPath() QString Folder::cleanPath()
{ {
QString cleanedPath = QDir::cleanPath(_definition.localPath); QString cleanedPath = QDir::cleanPath(_canonicalLocalPath);
if(cleanedPath.length() == 3 && cleanedPath.endsWith(":/")) if(cleanedPath.length() == 3 && cleanedPath.endsWith(":/"))
cleanedPath.remove(2,1); cleanedPath.remove(2,1);

View file

@ -288,6 +288,7 @@ private:
AccountStatePtr _accountState; AccountStatePtr _accountState;
FolderDefinition _definition; FolderDefinition _definition;
QString _canonicalLocalPath; // As returned with QFileInfo:canonicalFilePath. Always ends with "/"
SyncResult _syncResult; SyncResult _syncResult;
QScopedPointer<SyncEngine> _engine; QScopedPointer<SyncEngine> _engine;