allow sending parallel batch of files: curretly disabled
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 25 Nov 2021 21:11:59 +0000 (22:11 +0100)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 26 Nov 2021 15:32:08 +0000 (16:32 +0100)
can allow to send a new batch before the reply to a previous one is
received

due to concerns with the reliability on the server side this is disabled

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/bulkpropagatorjob.cpp
src/libsync/bulkpropagatorjob.h

index f6ab1ff3a52a0cec68429922dcf90fa62033bea9..ac66b41b3cb3f9d58f06c3342117754a73bbe0b0 100644 (file)
@@ -66,6 +66,7 @@ QByteArray getHeaderFromJsonReply(const QJsonObject &reply, const QByteArray &he
 
 constexpr auto batchSize = 100;
 
+constexpr auto parallelJobsMaximumCount = 1;
 }
 
 namespace OCC {
@@ -107,7 +108,7 @@ bool BulkPropagatorJob::scheduleSelfOrChild()
 
 PropagatorJob::JobParallelism BulkPropagatorJob::parallelism()
 {
-    return PropagatorJob::JobParallelism::WaitForFinished;
+    return PropagatorJob::JobParallelism::FullParallelism;
 }
 
 void BulkPropagatorJob::startUploadFile(SyncFileItemPtr item, UploadFileInfo fileToUpload)
@@ -225,6 +226,9 @@ void BulkPropagatorJob::triggerUpload()
     adjustLastJobTimeout(job.get(), timeout);
     _jobs.append(job.get());
     job.release()->start();
+    if (parallelism() == PropagatorJob::JobParallelism::FullParallelism && _jobs.size() < parallelJobsMaximumCount) {
+        scheduleSelfOrChild();
+    }
 }
 
 void BulkPropagatorJob::slotComputeTransmissionChecksum(SyncFileItemPtr item,
@@ -378,7 +382,7 @@ void BulkPropagatorJob::slotPutFinished()
         slotPutFinishedOneFile(singleFile, job, singleReplyObject);
     }
 
-    finalize();
+    finalize(fullReplyObject);
 }
 
 void BulkPropagatorJob::slotUploadProgress(SyncFileItemPtr item, qint64 sent, qint64 total)
@@ -438,18 +442,23 @@ void BulkPropagatorJob::finalizeOneFile(const BulkUploadItem &oneFile)
     propagator()->_journal->commit("upload file start");
 }
 
-void BulkPropagatorJob::finalize()
+void BulkPropagatorJob::finalize(const QJsonObject &fullReply)
 {
-    for(const auto &oneFile : _filesToUpload) {
-        if (!oneFile._item->hasErrorStatus()) {
-            finalizeOneFile(oneFile);
+    for(auto singleFileIt = std::begin(_filesToUpload); singleFileIt != std::end(_filesToUpload); ) {
+        const auto &singleFile = *singleFileIt;
+
+        if (!fullReply.contains(singleFile._remotePath)) {
+            ++singleFileIt;
+            continue;
+        }
+        if (!singleFile._item->hasErrorStatus()) {
+            finalizeOneFile(singleFile);
         }
 
-        done(oneFile._item, oneFile._item->_status, {});
-    }
+        done(singleFile._item, singleFile._item->_status, {});
 
-    Q_ASSERT(!_filesToUpload.empty());
-    _filesToUpload.clear();
+        singleFileIt = _filesToUpload.erase(singleFileIt);
+    }
 
     if (_items.empty()) {
         if (!_jobs.empty()) {
index bee2e29fa23ca2a899af334fec1e178f1c4d3095..e4846f04102293cd471836c01658dcff46b1d1cd 100644 (file)
@@ -98,7 +98,7 @@ private:
     void adjustLastJobTimeout(AbstractNetworkJob *job,
                               qint64 fileSize) const;
 
-    void finalize();
+    void finalize(const QJsonObject &fullReply);
 
     void finalizeOneFile(const BulkUploadItem &oneFile);