From b3fb730d5a7e0dfb137a62abf0bbfe41c61b8fb2 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Wed, 17 Jun 2020 15:06:48 +0200 Subject: [PATCH] Use the propagator to trigger the e2e info fetch This is a much better place than the GUI, this way we ensure the propagator is always operating of up to date information. Previously if the propagator kicked in without user interaction from startup (not showing the settings dialog) it would have no E2E information available whatsoever... unsurprisingly it would thus take wrong information at every turn. Signed-off-by: Kevin Ottens --- src/gui/folderstatusmodel.cpp | 6 ------ src/libsync/owncloudpropagator.cpp | 17 ++++++++++++++++- src/libsync/owncloudpropagator.h | 2 ++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index ce268f7a3..c337d8351 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -581,12 +581,6 @@ void FolderStatusModel::fetchMore(const QModelIndex &parent) path += info->_path; } - //TODO: This is the correct place, but this doesn't seems to be the right - // Way to call fetchFolderEncryptedStatus. - if (_accountState->account()->capabilities().clientSideEncryptionAvailable()) { - _accountState->account()->e2e()->fetchFolderEncryptedStatus(); - } - auto *job = new LsColJob(_accountState->account(), path, this); info->_fetchingJob = job; job->setProperties(QList() << "resourcetype" diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 7a1274bd7..6ba0086e2 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -510,7 +510,15 @@ void OwncloudPropagator::start(const SyncFileItemVector &items, connect(_rootJob.data(), &PropagatorJob::finished, this, &OwncloudPropagator::emitFinished); - scheduleNextJob(); + // If needed, make sure we have up to date E2E information before scheduling the first job + // otherwise we start right away + if (_account->capabilities().clientSideEncryptionAvailable()) { + connect(_account->e2e(), &ClientSideEncryption::folderEncryptedStatusFetchDone, + this, &OwncloudPropagator::onFolderEncryptedStatusFetchDone); + _account->e2e()->fetchFolderEncryptedStatus(); + } else { + scheduleNextJob(); + } } const SyncOptions &OwncloudPropagator::syncOptions() const @@ -608,6 +616,13 @@ QString OwncloudPropagator::getFilePath(const QString &tmp_file_name) const return _localDir + tmp_file_name; } +void OwncloudPropagator::onFolderEncryptedStatusFetchDone() +{ + disconnect(_account->e2e(), &ClientSideEncryption::folderEncryptedStatusFetchDone, + this, &OwncloudPropagator::onFolderEncryptedStatusFetchDone); + scheduleNextJob(); +} + void OwncloudPropagator::scheduleNextJob() { QTimer::singleShot(0, this, &OwncloudPropagator::scheduleNextJobImpl); diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index af944e8e9..d0cd59e53 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -527,6 +527,8 @@ private slots: _finishedEmited = true; } + void onFolderEncryptedStatusFetchDone(); + void scheduleNextJobImpl(); signals: -- 2.30.2