From 5a07a36d06c26ea2943926ec8a2afe962a4f87d4 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Wed, 1 Jul 2020 14:12:18 +0200 Subject: [PATCH] Avoid job parallelism when uploading to an encrypted folder With the current design of the file upload this necessarily pushed to a lock starvation on the folder. Indeed you could end up with N jobs asking for the lock at the same time. So just avoid parallelizing for now even though it will be slow. We could try to optimize but that'd require some serious changes to the sync logic on the jobs... let's stabilize first and optimize later. Signed-off-by: Kevin Ottens --- src/libsync/propagateupload.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index 24b555242..287c92c4f 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -172,6 +172,33 @@ PropagateUploadFileCommon::PropagateUploadFileCommon(OwncloudPropagator *propaga , _uploadEncryptedHelper(nullptr) , _uploadingEncrypted(false) { + 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 PropagateUploadFileCommon::parallelism() -- 2.30.2