[Pkg-owncloud-commits] [owncloud-client] 29/120: Progress: Guard against decreasing progress #3579

Sandro Knauß hefee-guest at moszumanska.debian.org
Mon Aug 24 00:02:40 UTC 2015


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 3ab49143e1d1580b60bd8b455903b817c688506b
Author: Christian Kamm <mail at ckamm.de>
Date:   Tue Aug 11 10:38:04 2015 +0200

    Progress: Guard against decreasing progress #3579
    
    Ensure that progress going backwards won't lead to outrageous
    transfer speeds.
---
 src/libsync/progressdispatcher.cpp | 15 +++++++++++----
 src/libsync/progressdispatcher.h   |  8 +++++++-
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/libsync/progressdispatcher.cpp b/src/libsync/progressdispatcher.cpp
index caaf8e0..9627ff3 100644
--- a/src/libsync/progressdispatcher.cpp
+++ b/src/libsync/progressdispatcher.cpp
@@ -182,7 +182,7 @@ quint64 ProgressInfo::completedSize() const
 void ProgressInfo::setProgressComplete(const SyncFileItem &item)
 {
     _currentItems.remove(item._file);
-    _fileProgress._completed += item._affectedItems;
+    _fileProgress.setCompleted(_fileProgress._completed + item._affectedItems);
     if (ProgressInfo::isSizeDependent(item)) {
         _totalSizeOfCompletedJobs += item._size;
     }
@@ -190,11 +190,11 @@ void ProgressInfo::setProgressComplete(const SyncFileItem &item)
     _lastCompletedItem = item;
 }
 
-void ProgressInfo::setProgressItem(const SyncFileItem &item, quint64 size)
+void ProgressInfo::setProgressItem(const SyncFileItem &item, quint64 completed)
 {
     _currentItems[item._file]._item = item;
-    _currentItems[item._file]._progress._completed = size;
     _currentItems[item._file]._progress._total = item._size;
+    _currentItems[item._file]._progress.setCompleted(completed);
     recomputeCompletedSize();
 
     // This seems dubious!
@@ -273,7 +273,7 @@ void ProgressInfo::recomputeCompletedSize()
         if (isSizeDependent(i._item))
             r += i._progress._completed;
     }
-    _sizeProgress._completed = r;
+    _sizeProgress.setCompleted(r);
 }
 
 ProgressInfo::Estimates ProgressInfo::Progress::estimates() const
@@ -314,5 +314,12 @@ void ProgressInfo::Progress::update()
     _prevCompleted = _completed;
 }
 
+void ProgressInfo::Progress::setCompleted(quint64 completed)
+{
+    _completed = completed;
+    _prevCompleted = qMin(_prevCompleted, completed);
+    _total = qMax(_total, completed);
+}
+
 
 }
diff --git a/src/libsync/progressdispatcher.h b/src/libsync/progressdispatcher.h
index 6a04d3c..e9b85c3 100644
--- a/src/libsync/progressdispatcher.h
+++ b/src/libsync/progressdispatcher.h
@@ -126,6 +126,12 @@ public:
          */
         void update();
 
+        /**
+         * Changes the _completed value and does sanity checks on
+         * _prevCompleted and _total.
+         */
+        void setCompleted(quint64 completed);
+
         // Updated by update()
         double _progressPerSec;
         quint64 _prevCompleted;
@@ -155,7 +161,7 @@ public:
 
     void setProgressComplete(const SyncFileItem &item);
 
-    void setProgressItem(const SyncFileItem &item, quint64 size);
+    void setProgressItem(const SyncFileItem &item, quint64 completed);
 
     /**
      * Get the total completion estimate

-- 
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