Always use an absolute remote path for GetFolderEncryptStatusJob
authorKevin Ottens <kevin.ottens@nextcloud.com>
Mon, 29 Jun 2020 16:16:59 +0000 (18:16 +0200)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Wed, 1 Jul 2020 16:58:29 +0000 (16:58 +0000)
It turns out this job expected an absolute remote path even in the case
of a subfolder sync point.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/libsync/propagatedownloadencrypted.cpp
src/libsync/propagateuploadencrypted.cpp

index 4b989f59eb18690e1c4c15e3b66ed35ceb02275c..3b284e9f7888c62bd9853ecfff17e50c9a1e5664 100644 (file)
@@ -21,7 +21,18 @@ void PropagateDownloadEncrypted::start() {
 
 void PropagateDownloadEncrypted::checkFolderEncryptedStatus()
 {
-  auto getEncryptedStatus = new GetFolderEncryptStatusJob(_propagator->account(), _info.path());
+    const auto rootPath = [=]() {
+        const auto result = _propagator->_remoteFolder;
+        if (result.startsWith('/')) {
+            return result.mid(1);
+        } else {
+            return result;
+        }
+    }();
+    const auto remotePath = QString(rootPath + _item->_file);
+    const auto remoteParentPath = remotePath.left(remotePath.lastIndexOf('/'));
+
+  auto getEncryptedStatus = new GetFolderEncryptStatusJob(_propagator->account(), remoteParentPath, this);
   connect(getEncryptedStatus, &GetFolderEncryptStatusJob::encryptStatusFolderReceived,
           this, &PropagateDownloadEncrypted::folderStatusReceived);
 
index f8cce69ae045a7d615ebf0cc8721ed330e458c31..3bea68ffe1591520517e6ef3b6e838e5ccc8b29b 100644 (file)
@@ -27,6 +27,23 @@ PropagateUploadEncrypted::PropagateUploadEncrypted(OwncloudPropagator *propagato
 
 void PropagateUploadEncrypted::start()
 {
+    const auto rootPath = [=]() {
+        const auto result = _propagator->_remoteFolder;
+        if (result.startsWith('/')) {
+            return result.mid(1);
+        } else {
+            return result;
+        }
+    }();
+    const auto absoluteRemoteParentPath = [=]{
+        auto path = QString(rootPath + _remoteParentPath);
+        if (path.endsWith('/')) {
+            path.chop(1);
+        }
+        return path;
+    }();
+
+
   /* If the file is in a encrypted-enabled nextcloud instance, we need to
       * do the long road: Fetch the folder status of the encrypted bit,
       * if it's encrypted, find the ID of the folder.
@@ -40,7 +57,7 @@ void PropagateUploadEncrypted::start()
       * If the folder is unencrypted we just follow the old way.
       */
       qCDebug(lcPropagateUploadEncrypted) << "Starting to send an encrypted file!";
-      auto getEncryptedStatus = new GetFolderEncryptStatusJob(_propagator->account(), _remoteParentPath, this);
+      auto getEncryptedStatus = new GetFolderEncryptStatusJob(_propagator->account(), absoluteRemoteParentPath, this);
 
       connect(getEncryptedStatus, &GetFolderEncryptStatusJob::encryptStatusFolderReceived,
               this, &PropagateUploadEncrypted::slotFolderEncryptedStatusFetched);