Merge pull request #2144 from nextcloud/fix_e2ee_upload_lock_starvation

Fix e2ee upload lock starvation
This commit is contained in:
Kevin Ottens 2020-07-01 19:22:45 +02:00 committed by GitHub
commit be4ba031ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 8 deletions

View file

@ -164,6 +164,48 @@ bool PollJob::finished()
return true; return true;
} }
PropagateUploadFileCommon::PropagateUploadFileCommon(OwncloudPropagator *propagator, const SyncFileItemPtr &item)
: PropagateItemJob(propagator, item)
, _finished(false)
, _deleteExisting(false)
, _parallelism(FullParallelism)
, _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()
{
return _parallelism;
}
void PropagateUploadFileCommon::setDeleteExisting(bool enabled) void PropagateUploadFileCommon::setDeleteExisting(bool enabled)
{ {
_deleteExisting = enabled; _deleteExisting = enabled;

View file

@ -226,16 +226,12 @@ protected:
}; };
UploadFileInfo _fileToUpload; UploadFileInfo _fileToUpload;
QByteArray _transmissionChecksumHeader; QByteArray _transmissionChecksumHeader;
JobParallelism _parallelism;
public: public:
PropagateUploadFileCommon(OwncloudPropagator *propagator, const SyncFileItemPtr &item) PropagateUploadFileCommon(OwncloudPropagator *propagator, const SyncFileItemPtr &item);
: PropagateItemJob(propagator, item)
, _finished(false) JobParallelism parallelism() override;
, _deleteExisting(false)
, _uploadEncryptedHelper(nullptr)
, _uploadingEncrypted(false)
{
}
/** /**
* Whether an existing entity with the same name may be deleted before * Whether an existing entity with the same name may be deleted before