[Sharing] Make sure the file is actually synced to the server
authorRoeland Jago Douma <rullzer@owncloud.com>
Fri, 20 Nov 2015 08:26:45 +0000 (09:26 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Wed, 25 Nov 2015 08:22:20 +0000 (09:22 +0100)
Before we attemt any sharing make sure the file is synced to the server.

src/gui/socketapi.cpp

index 3dde1e5c7122c22f6f81287ff6b585f2f4797c86..6dfbfd3fe8bd07bd73182d6ef02d8ec2ff448be3 100644 (file)
@@ -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;
         }