[Pkg-owncloud-commits] [owncloud-client] 43/219: Propagator: When the server don't support ranges, reset the counter so the progress is not messed up

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 11 14:43:07 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 5d194269304eb33e8ea46e8ec63dde574a6915ba
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Fri Aug 29 19:23:08 2014 +0200

    Propagator: When the server don't support ranges, reset the counter so the progress is not messed up
    
    Issue #2081
---
 src/mirall/propagator_qnam.cpp | 11 +++++++----
 src/mirall/propagator_qnam.h   |  4 ++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index d066d25..68016fa 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -484,7 +484,7 @@ void GETFileJob::slotMetaDataChanged()
     }
 
     quint64 start = 0;
-    QByteArray ranges = parseEtag(reply()->rawHeader("Content-Range"));
+    QByteArray ranges = reply()->rawHeader("Content-Range");
     if (!ranges.isEmpty()) {
         QRegExp rx("bytes (\\d+)-");
         if (rx.indexIn(ranges) >= 0) {
@@ -502,6 +502,7 @@ void GETFileJob::slotMetaDataChanged()
                 reply()->abort();
                 return;
             }
+            _resumeStart = 0;
         } else {
             _errorString = tr("Server returned wrong content-range");
             _errorStatus = SyncFileItem::NormalError;
@@ -606,6 +607,7 @@ void PropagateDownloadFileQNAM::start()
 
     QMap<QByteArray, QByteArray> headers;
 
+    quint64 startSize = 0;
     if (_tmpFile.size() > 0) {
         quint64 done = _tmpFile.size();
         if (done == _item._size) {
@@ -616,14 +618,14 @@ void PropagateDownloadFileQNAM::start()
         headers["Range"] = "bytes=" + QByteArray::number(done) +'-';
         headers["Accept-Ranges"] = "bytes";
         qDebug() << "Retry with range " << headers["Range"];
-        _startSize = done;
+        startSize = done;
     }
 
     if (_item._directDownloadUrl.isEmpty()) {
         // Normal job, download from oC instance
         _job = new GETFileJob(AccountManager::instance()->account(),
                             _propagator->_remoteFolder + _item._file,
-                            &_tmpFile, headers, expectedEtagForResume, _startSize);
+                            &_tmpFile, headers, expectedEtagForResume, startSize);
     } else {
         // We were provided a direct URL, use that one
         if (!_item._directDownloadCookies.isEmpty()) {
@@ -748,7 +750,8 @@ void PropagateDownloadFileQNAM::downloadFinished()
 
 void PropagateDownloadFileQNAM::slotDownloadProgress(qint64 received, qint64)
 {
-    emit progress(_item, received + _startSize);
+    if (!_job) return;
+    emit progress(_item, received + _job->resumeStart());
 }
 
 
diff --git a/src/mirall/propagator_qnam.h b/src/mirall/propagator_qnam.h
index 7b4c657..9ef37f3 100644
--- a/src/mirall/propagator_qnam.h
+++ b/src/mirall/propagator_qnam.h
@@ -139,6 +139,7 @@ public:
     virtual void slotTimeout() Q_DECL_OVERRIDE;
 
     QByteArray &etag() { return _etag; }
+    quint64 resumeStart() { return _resumeStart; }
 
 
 signals:
@@ -156,10 +157,9 @@ class PropagateDownloadFileQNAM : public PropagateItemJob {
 
 //  QFile *_file;
     QFile _tmpFile;
-    quint64 _startSize;
 public:
     PropagateDownloadFileQNAM(OwncloudPropagator* propagator,const SyncFileItem& item)
-        : PropagateItemJob(propagator, item), _startSize(0) {}
+        : PropagateItemJob(propagator, item) {}
     void start() Q_DECL_OVERRIDE;
 private slots:
     void slotGetFinished();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list