Merge pull request #2821 from nextcloud/e2ee-fix-parallel-uploads-issue

E2EE fix upload parallelism issue.
This commit is contained in:
Kevin Ottens 2021-01-14 11:41:52 +01:00 committed by GitHub
commit 4a1c650a56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 41 deletions

View file

@ -301,6 +301,29 @@ void PropagateItemJob::slotRestoreJobFinished(SyncFileItem::Status status)
}
}
bool PropagateItemJob::hasEncryptedAncestor() const
{
if (!propagator()->account()->capabilities().clientSideEncryptionAvailable()) {
return false;
}
const auto path = _item->_file;
const auto slashPosition = path.lastIndexOf('/');
const auto parentPath = slashPosition >= 0 ? path.left(slashPosition) : QString();
auto pathComponents = parentPath.split('/');
while (!pathComponents.isEmpty()) {
SyncJournalFileRecord rec;
propagator()->_journal->getFileRecord(pathComponents.join('/'), &rec);
if (rec.isValid() && rec._isE2eEncrypted) {
return true;
}
pathComponents.removeLast();
}
return false;
}
// ================================================================================
PropagateItemJob *OwncloudPropagator::createJob(const SyncFileItemPtr &item)

View file

@ -171,6 +171,8 @@ protected:
_item->_errorString = msg;
}
bool hasEncryptedAncestor() const;
protected slots:
void slotRestoreJobFinished(SyncFileItem::Status status);

View file

@ -34,14 +34,6 @@ PropagateRemoteMkdir::PropagateRemoteMkdir(OwncloudPropagator *propagator, const
, _uploadEncryptedHelper(nullptr)
, _parallelism(FullParallelism)
{
const auto rootPath = [=]() {
const auto result = propagator->remotePath();
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();
@ -52,11 +44,7 @@ PropagateRemoteMkdir::PropagateRemoteMkdir(OwncloudPropagator *propagator, const
return;
}
const auto account = propagator->account();
if (account->capabilities().clientSideEncryptionAvailable() &&
parentRec.isValid() &&
parentRec._isE2eEncrypted) {
if (hasEncryptedAncestor()) {
_parallelism = WaitForFinished;
}
}
@ -142,14 +130,6 @@ void PropagateRemoteMkdir::setDeleteExisting(bool enabled)
void PropagateRemoteMkdir::slotMkdir()
{
const auto rootPath = [=]() {
const auto result = propagator()->remotePath();
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();
@ -161,21 +141,7 @@ void PropagateRemoteMkdir::slotMkdir()
return;
}
const auto hasEncryptedAncestor = [=] {
auto pathComponents = parentPath.split('/');
while (!pathComponents.isEmpty()) {
SyncJournalFileRecord rec;
propagator()->_journal->getFileRecord(pathComponents.join('/'), &rec);
if (rec.isValid() && rec._isE2eEncrypted) {
return true;
}
pathComponents.removeLast();
}
return false;
}();
const auto account = propagator()->account();
if (!account->capabilities().clientSideEncryptionAvailable() || !hasEncryptedAncestor) {
if (!hasEncryptedAncestor()) {
slotStartMkcolJob();
return;
}

View file

@ -206,11 +206,7 @@ PropagateUploadFileCommon::PropagateUploadFileCommon(OwncloudPropagator *propaga
return;
}
const auto account = propagator->account();
if (account->capabilities().clientSideEncryptionAvailable() &&
parentRec.isValid() &&
parentRec._isE2eEncrypted) {
if (hasEncryptedAncestor()) {
_parallelism = WaitForFinished;
}
}