Use the propagator to trigger the e2e info fetch
authorKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 17 Jun 2020 13:06:48 +0000 (15:06 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 30 Jun 2020 09:29:08 +0000 (11:29 +0200)
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 <kevin.ottens@nextcloud.com>
src/gui/folderstatusmodel.cpp
src/libsync/owncloudpropagator.cpp
src/libsync/owncloudpropagator.h

index ce268f7a3561a3a4b76db7ed142482dd65c79e3b..c337d8351a2cb1b20f7acdb8a3b80c3ad312ad3a 100644 (file)
@@ -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<QByteArray>() << "resourcetype"
index 7a1274bd73e5dccb01c09930071a81dfaa7ec35c..6ba0086e28729a740ee4d998eaf0fc63ea5a2d82 100644 (file)
@@ -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);
index af944e8e9455730e650de833c86fb2988c7f8fe2..d0cd59e5351c95b43a1f41c0927d6dda702b3ed5 100644 (file)
@@ -527,6 +527,8 @@ private slots:
         _finishedEmited = true;
     }
 
+    void onFolderEncryptedStatusFetchDone();
+
     void scheduleNextJobImpl();
 
 signals: