From: Kevin Ottens Date: Wed, 1 Jul 2020 12:12:18 +0000 (+0200) Subject: Avoid job parallelism when uploading to an encrypted folder X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~222^2^2~124^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5a07a36d06c26ea2943926ec8a2afe962a4f87d4;p=nextcloud-desktop.git 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 --- 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()