batch upload: only handle file that are in the reply
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 25 Nov 2021 15:48:10 +0000 (16:48 +0100)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 26 Nov 2021 14:49:25 +0000 (15:49 +0100)
do not handle all files sent but only received ones

should allow to submit more than one request in parallel

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

index bd120d4fe9806703e24f0631d47ce66e1e3b5c23..2d5362a94f736e09c7c35db672a43fd21faae7b2 100644 (file)
@@ -301,11 +301,10 @@ void BulkPropagatorJob::slotOnErrorStartFolderUnlock(SyncFileItemPtr item,
 
 void BulkPropagatorJob::slotPutFinishedOneFile(const BulkUploadItem &singleFile,
                                                PutMultiFileJob *job,
-                                               const QJsonObject &fullReplyObject)
+                                               const QJsonObject &fileReply)
 {
     bool finished = false;
 
-    const auto fileReply = fullReplyObject.value(QChar('/') + singleFile._item->_file).toObject();
     qCInfo(lcBulkPropagatorJob()) << singleFile._item->_file << "file headers" << fileReply;
 
     if (!fileReply[QStringLiteral("error")].toBool()) {
@@ -371,8 +370,12 @@ void BulkPropagatorJob::slotPutFinished()
     const auto replyJson = QJsonDocument::fromJson(replyData);
     const auto fullReplyObject = replyJson.object();
 
-    for (const auto &oneFile : _filesToUpload) {
-        slotPutFinishedOneFile(oneFile, job, fullReplyObject);
+    for (const auto &singleFile : _filesToUpload) {
+        if (!fullReplyObject.contains(singleFile._remotePath)) {
+            continue;
+        }
+        const auto singleReplyObject = fullReplyObject[singleFile._remotePath].toObject();
+        slotPutFinishedOneFile(singleFile, job, singleReplyObject);
     }
 
     finalize();