Disable parallelism if we think the parent is e2e
authorKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 15 Jul 2020 11:05:54 +0000 (13:05 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 15 Jul 2020 11:05:54 +0000 (13:05 +0200)
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/libsync/propagateremotemkdir.cpp

index a44e8e93e3e35ac0e69ce197de7056ff6bccf858..d19bcf4818315c9b016a58e651435e2e43ba9b6b 100644 (file)
@@ -34,6 +34,33 @@ PropagateRemoteMkdir::PropagateRemoteMkdir(OwncloudPropagator *propagator, const
     , _uploadEncryptedHelper(nullptr)
     , _parallelism(FullParallelism)
 {
+    const auto rootPath = [=]() {
+        const auto result = propagator->_remoteFolder;
+        if (result.startsWith('/')) {
+            return result.mid(1);
+        } else {
+            return result;
+        }
+    }();
+    const auto path = _item->_file;
+    const auto slashPosition = path.lastIndexOf('/');
+    const auto parentPath = slashPosition >= 0 ? path.left(slashPosition) : QString();
+
+    SyncJournalFileRecord parentRec;
+    bool ok = propagator->_journal->getFileRecord(parentPath, &parentRec);
+    if (!ok) {
+        done(SyncFileItem::NormalError);
+        return;
+    }
+
+    const auto remoteParentPath = parentRec._e2eMangledName.isEmpty() ? parentPath : parentRec._e2eMangledName;
+    const auto absoluteRemoteParentPath = remoteParentPath.isEmpty() ? rootPath : rootPath + remoteParentPath + '/';
+    const auto account = propagator->account();
+
+    if (account->capabilities().clientSideEncryptionAvailable() &&
+        account->e2e()->isFolderEncrypted(absoluteRemoteParentPath)) {
+        _parallelism = WaitForFinished;
+    }
 }
 
 PropagatorJob::JobParallelism PropagateRemoteMkdir::parallelism()