From 1b62ed1e7e49795ee892268f16425e77bf7da6ce Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 18 Sep 2014 12:36:30 +0200 Subject: [PATCH] Parallel chunk upload: Fix progress --- src/mirall/propagator_qnam.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp index 6b525324f..9f3d50adc 100644 --- a/src/mirall/propagator_qnam.cpp +++ b/src/mirall/propagator_qnam.cpp @@ -262,12 +262,9 @@ void PropagateUploadFileQNAM::startNextChunk() // Don't do parallel upload of chunk if this might be the last chunk because the server cannot handle that // https://github.com/owncloud/core/issues/11106 // We return now and when the _jobs will be finished we will proceed the last chunk - qWarning() << "WTF" << _currentChunk << _chunkCount << _startChunk; return; } - qWarning() << "Go Go Go " << _jobs.count() << _currentChunk << _chunkCount << _startChunk; - /* * // If the source file has changed during upload, it is detected and the * // variable _previousFileSize is set accordingly. The propagator waits a @@ -504,7 +501,17 @@ void PropagateUploadFileQNAM::slotUploadProgress(qint64 sent, qint64) int progressChunk = _currentChunk + _startChunk - 1; if (progressChunk >= _chunkCount) progressChunk = _currentChunk - 1; - emit progress(_item, sent + progressChunk * chunkSize()); + quint64 amount = progressChunk * chunkSize(); + sender()->setProperty("byteWritten", sent); + if (_jobs.count() == 1) { + amount += sent; + } else { + amount -= (_jobs.count() -1) * chunkSize(); + foreach (QObject *j, _jobs) { + amount += j->property("byteWritten").toULongLong(); + } + } + emit progress(_item, amount); } void PropagateUploadFileQNAM::startPollJob(const QString& path)