@@ -58,7 +58,6 @@ QByteArray getHeaderFromJsonReply(const QJsonObject &reply, const QByteArray &he
5858 return reply.value (headerName).toString ().toLatin1 ();
5959}
6060
61- constexpr auto batchSize = 100 ;
6261constexpr auto parallelJobsMaximumCount = 1 ;
6362
6463}
@@ -70,10 +69,10 @@ Q_LOGGING_CATEGORY(lcBulkPropagatorJob, "nextcloud.sync.propagator.bulkupload",
7069BulkPropagatorJob::BulkPropagatorJob (OwncloudPropagator *propagator, const std::deque<SyncFileItemPtr> &items)
7170 : PropagatorJob(propagator)
7271 , _items(items)
73- , _currentBatchSize(batchSize )
72+ , _currentBatchSize(_items.size() )
7473{
75- _filesToUpload.reserve (batchSize );
76- _pendingChecksumFiles.reserve (batchSize );
74+ _filesToUpload.reserve (_items. size () );
75+ _pendingChecksumFiles.reserve (_items. size () );
7776}
7877
7978bool BulkPropagatorJob::scheduleSelfOrChild ()
@@ -84,11 +83,15 @@ bool BulkPropagatorJob::scheduleSelfOrChild()
8483
8584 _state = Running;
8685
87- for (auto i = 0 ; i < _currentBatchSize && !_items.empty (); ++i) {
86+ qCDebug (lcBulkPropagatorJob ()) << " max chunk size" << PropagatorJob::propagator ()->syncOptions ().maxChunkSize ();
87+
88+ for (auto batchDataSize = 0 ; batchDataSize <= PropagatorJob::propagator ()->syncOptions ().maxChunkSize () && !_items.empty (); ) {
8889 const auto currentItem = _items.front ();
8990 _items.pop_front ();
9091 _pendingChecksumFiles.insert (currentItem->_file );
9192
93+ batchDataSize += currentItem->_size ;
94+
9295 QMetaObject::invokeMethod (this , [this , currentItem] {
9396 UploadFileInfo fileToUpload;
9497 fileToUpload._file = currentItem->_file ;
@@ -117,7 +120,7 @@ bool BulkPropagatorJob::handleBatchSize()
117120 }
118121
119122 // change batch size before trying it again
120- const auto halfBatchSize = batchSize / 2 ;
123+ const auto halfBatchSize = static_cast < int >(_items. size () / 2 ) ;
121124
122125 // we already tried to upload with half of the batch size
123126 if (_currentBatchSize == halfBatchSize) {
@@ -221,7 +224,6 @@ void BulkPropagatorJob::doStartUpload(SyncFileItemPtr item,
221224 remotePath, fileToUpload._path ,
222225 fileToUpload._size , currentHeaders};
223226
224- qCInfo (lcBulkPropagatorJob) << remotePath << " transmission checksum" << transmissionChecksumHeader << fileToUpload._path ;
225227 _filesToUpload.push_back (std::move (newUploadFile));
226228 _pendingChecksumFiles.remove (item->_file );
227229
@@ -583,7 +585,7 @@ void BulkPropagatorJob::finalizeOneFile(const BulkUploadItem &oneFile)
583585
584586void BulkPropagatorJob::finalize (const QJsonObject &fullReply)
585587{
586- qCDebug (lcBulkPropagatorJob) << " Received a full reply" << fullReply;
588+ qCDebug (lcBulkPropagatorJob) << " Received a full reply" << QJsonDocument::fromVariant ( fullReply). toJson () ;
587589
588590 for (auto singleFileIt = std::begin (_filesToUpload); singleFileIt != std::end (_filesToUpload); ) {
589591 const auto &singleFile = *singleFileIt;
0 commit comments