From: Kevin Ottens Date: Mon, 7 Dec 2020 15:33:36 +0000 (+0100) Subject: Don't use getFileRecordByE2eMangledName in jobs anymore X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~45 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=af00ef1cca521bb92d27b0db07edec60f94cd09f;p=nextcloud-desktop.git Don't use getFileRecordByE2eMangledName in jobs anymore 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 --- diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index e032ffd6b..f3348a152 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -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] { diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index 46a078d50..b286c1504 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -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)