E2EE fix upload parallelism issue.

Signed-off-by: allexzander <blackslayer4@gmail.com>
This commit is contained in:
allexzander 2021-01-13 16:34:08 +02:00 committed by allexzander (Rebase PR Action)
parent 6656b23922
commit bf5b214e0e
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;
}
}