From 9f15ba3972c806f836a2412339959b7dbbc806c7 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 20 Nov 2015 09:26:45 +0100 Subject: [PATCH 1/2] [Sharing] Make sure the file is actually synced to the server Before we attemt any sharing make sure the file is synced to the server. --- src/gui/socketapi.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index 3dde1e5c71..6dfbfd3fe8 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -378,12 +378,23 @@ 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); + SyncFileStatus fileStatus = this->fileStatus(shareFolder, file); + + // Verify the file is on the server (to our knowledge of course) + if (fileStatus.tag() != SyncFileStatus::STATUS_SYNC && + fileStatus.tag() != SyncFileStatus::STATUS_UPDATED) { + const QString message = QLatin1String("SHARE:NOTSYNCED:")+QDir::toNativeSeparators(localFile); + sendMessage(socket, message); + return; + } + const QString folderForPath = shareFolder->path(); const QString remotePath = shareFolder->remotePath() + localFile.right(localFile.count()-folderForPath.count()+1); // Can't share root folder if (QDir::cleanPath(remotePath) == "/") { - const QString message = QLatin1String("SHARE:CANNOTSHAREROOT:")+QDir::toNativeSeparators(localFile); + const QString message = QLatin1String("SHARE:CANNOTSHAREROOT:")+QDir::toNativeSeparators(localFile); sendMessage(socket, message); return; } From fcdab1e80404570bdb3a24585e616953a3c75b25 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 25 Nov 2015 09:40:21 +0100 Subject: [PATCH 2/2] [Sharing] Also add sync status to SHARE_STATUS command --- src/gui/socketapi.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index 6dfbfd3fe8..1f75ad5d5f 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -435,6 +435,17 @@ void SocketApi::command_SHARE_STATUS(const QString &localFile, QIODevice *socket const QString message = QLatin1String("SHARE_STATUS:NOP:")+QDir::toNativeSeparators(localFile); sendMessage(socket, message); } else { + const QString file = QDir::cleanPath(localFile).mid(shareFolder->cleanPath().length()+1); + SyncFileStatus fileStatus = this->fileStatus(shareFolder, file); + + // Verify the file is on the server (to our knowledge of course) + if (fileStatus.tag() != SyncFileStatus::STATUS_SYNC && + fileStatus.tag() != SyncFileStatus::STATUS_UPDATED) { + const QString message = QLatin1String("SHARE_STATUS:NOTSYNCED:")+QDir::toNativeSeparators(localFile); + sendMessage(socket, message); + return; + } + const Capabilities capabilities = shareFolder->accountState()->account()->capabilities(); if (!capabilities.shareAPI()) {