From 970cdcfdbbd1e4b08d6f9677f42f27e6fd1ca720 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 4 Jan 2016 11:57:51 +0100 Subject: [PATCH] SocketAPI: SHARE: Fix the paths when creating the share dialog The socket api uses native folder separator. We need to use QDir::cleanPath for anything else so we only work with '/' everywhere else in the code This fixes the sharing dialog on window. Issue #4311 --- src/gui/socketapi.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index 4d0bf5f692..b9eb7cd5a1 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -374,7 +374,8 @@ void SocketApi::command_SHARE(const QString& localFile, QIODevice* socket) // if the folder isn't connected, don't open the share dialog sendMessage(socket, message); } else { - const QString file = QDir::cleanPath(localFile).mid(shareFolder->cleanPath().length()+1); + const QString localFileClean = QDir::cleanPath(localFile); + const QString file = localFileClean.mid(shareFolder->cleanPath().length()+1); SyncFileStatus fileStatus = this->fileStatus(shareFolder, file); // Verify the file is on the server (to our knowledge of course) @@ -385,17 +386,16 @@ void SocketApi::command_SHARE(const QString& localFile, QIODevice* socket) return; } - const QString folderForPath = shareFolder->path(); - const QString remotePath = shareFolder->remotePath() + localFile.right(localFile.count()-folderForPath.count()+1); + const QString remotePath = shareFolder->remotePath() + QLatin1Char('/') + file; // Can't share root folder - if (QDir::cleanPath(remotePath) == "/") { + if (remotePath == "/") { const QString message = QLatin1String("SHARE:CANNOTSHAREROOT:")+QDir::toNativeSeparators(localFile); sendMessage(socket, message); return; } - SyncJournalFileRecord rec = dbFileRecord_capi(shareFolder, localFile); + SyncJournalFileRecord rec = dbFileRecord_capi(shareFolder, localFileClean); bool allowReshare = true; // lets assume the good if( rec.isValid() ) { @@ -407,7 +407,7 @@ void SocketApi::command_SHARE(const QString& localFile, QIODevice* socket) const QString message = QLatin1String("SHARE:OK:")+QDir::toNativeSeparators(localFile); sendMessage(socket, message); - emit shareCommandReceived(remotePath, localFile, allowReshare); + emit shareCommandReceived(remotePath, localFileClean, allowReshare); } }