Don't use getFileRecordByE2eMangledName in jobs anymore
authorKevin Ottens <kevin.ottens@nextcloud.com>
Mon, 7 Dec 2020 15:33:36 +0000 (16:33 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:21 +0000 (10:59 +0100)
Thanks to the new discovery algorithm we got both mangled and original
file names in the item so no need to go through the database for
nothing.

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

index e032ffd6b55836b1879eb62028da9ea7ec592ad0..f3348a152bdf86d9e93ea79de7fe7b0407f9017e 100644 (file)
@@ -384,12 +384,9 @@ void PropagateDownloadFile::start()
         !account->e2e()->isFolderEncrypted(remoteParentPath + '/')) {
         startAfterIsEncryptedIsChecked();
     } else {
-        const auto slashPosition = remoteFilename.lastIndexOf('/');
-        const auto relativeRemoteParentPath = slashPosition >= 0 ? remoteFilename.left(slashPosition) : QString();
-
-        SyncJournalFileRecord parentRec;
-        propagator()->_journal->getFileRecordByE2eMangledName(relativeRemoteParentPath, &parentRec);
-        const auto parentPath = parentRec.isValid() ? parentRec._path : relativeRemoteParentPath;
+        const auto path = _item->_file;
+        const auto slashPosition = path.lastIndexOf('/');
+        const auto parentPath = slashPosition >= 0 ? path.left(slashPosition) : QString();
 
         _downloadEncryptedHelper = new PropagateDownloadEncrypted(propagator(), parentPath, _item, this);
         connect(_downloadEncryptedHelper, &PropagateDownloadEncrypted::folderStatusNotEncrypted, [this] {
index 46a078d501282e94d1a09e940cd867c8aef5aa78..b286c15040e9b64d1ae28a870f52737571bba5d6 100644 (file)
@@ -134,31 +134,7 @@ void PropagateLocalMkdir::start()
     if (propagator()->_abortRequested)
         return;
 
-    const auto rootPath = [=]() {
-        const auto result = propagator()->remotePath();
-        if (result.startsWith('/')) {
-            return result.mid(1);
-        } else {
-            return result;
-        }
-    }();
-    const auto remotePath = QString(rootPath + _item->_file);
-    const auto remoteParentPath = remotePath.left(remotePath.lastIndexOf('/'));
-
-    const auto account = propagator()->account();
-    if (!account->capabilities().clientSideEncryptionAvailable() ||
-        !account->e2e()->isFolderEncrypted(remoteParentPath + '/')) {
-        startLocalMkdir();
-    } else {
-        const auto relativeRemotePath = _item->_file;
-        const auto slashPosition = relativeRemotePath.lastIndexOf('/');
-        const auto relativeRemoteParentPath = slashPosition >= 0 ? relativeRemotePath.left(slashPosition) : QString();
-
-        SyncJournalFileRecord parentRec;
-        propagator()->_journal->getFileRecordByE2eMangledName(relativeRemoteParentPath, &parentRec);
-        const auto parentPath = parentRec.isValid() ? parentRec._path : relativeRemoteParentPath;
-        startDemanglingName(parentPath);
-    }
+    startLocalMkdir();
 }
 
 void PropagateLocalMkdir::setDeleteExistingFile(bool enabled)
@@ -223,24 +199,6 @@ void PropagateLocalMkdir::startLocalMkdir()
     done(resultStatus);
 }
 
-void PropagateLocalMkdir::startDemanglingName(const QString &parentPath)
-{
-    auto downloadEncryptedHelper = new PropagateDownloadEncrypted(propagator(), parentPath, _item, this);
-    connect(downloadEncryptedHelper, &PropagateDownloadEncrypted::folderStatusEncrypted,
-            this, &PropagateLocalMkdir::startLocalMkdir);
-    connect(downloadEncryptedHelper, &PropagateDownloadEncrypted::folderStatusNotEncrypted, this, [this] {
-        // We were wrong after all? Actually might happen due to legacy clients creating broken encrypted folders
-        qCDebug(lcPropagateLocalMkdir) << "Parent of" << _item->_file << "wasn't encrypted, creating with the original name";
-        startLocalMkdir();
-    });
-    connect(downloadEncryptedHelper, &PropagateDownloadEncrypted::failed, [this] {
-        // This also might happen due to legacy clients creating broken encrypted folders...
-        qCDebug(lcPropagateLocalMkdir) << "Directory" << _item->_file << "doesn't exist in its parent metadata, creating with the original name";
-        startLocalMkdir();
-    });
-    downloadEncryptedHelper->start();
-}
-
 void PropagateLocalRename::start()
 {
     if (propagator()->_abortRequested)