[Pkg-owncloud-commits] [owncloud-client] 36/498: Time estimation: Use a consistent check for size dependence. #2328

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Aug 11 14:48:31 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 7d68c628dbb496c855e77e186835be129abfc897
Author: Christian Kamm <kamm at incasoftware.de>
Date:   Fri Jan 30 09:17:15 2015 +0100

    Time estimation: Use a consistent check for size dependence. #2328
---
 src/gui/accountsettings.cpp      |  4 ++--
 src/gui/protocolwidget.cpp       |  2 +-
 src/libsync/progressdispatcher.h | 27 +++++++++++++++++----------
 src/libsync/syncengine.cpp       |  2 +-
 4 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index a685804..ac195cc 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -631,7 +631,7 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
     qint64 curItemProgress = -1; // -1 means finished
     quint64 biggerItemSize = -1;
     foreach(const Progress::Info::ProgressItem &citm, progress._currentItems) {
-        if (curItemProgress == -1 || (Progress::isSizeDependent(citm._item._instruction)
+        if (curItemProgress == -1 || (Progress::isSizeDependent(citm._item)
                                       && biggerItemSize < citm._item._size)) {
             curItemProgress = citm._completedSize;
             curItem = citm._item;
@@ -648,7 +648,7 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
 
 
     QString fileProgressString;
-    if (Progress::isSizeDependent(curItem._instruction)) {
+    if (Progress::isSizeDependent(curItem)) {
         QString s1 = Utility::octetsToString( curItemProgress );
         QString s2 = Utility::octetsToString( curItem._size );
         quint64 estimatedBw = progress.getFileEstimate(curItem).getEstimatedBandwidth();
diff --git a/src/gui/protocolwidget.cpp b/src/gui/protocolwidget.cpp
index 85e3f41..0bccd81 100644
--- a/src/gui/protocolwidget.cpp
+++ b/src/gui/protocolwidget.cpp
@@ -224,7 +224,7 @@ QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& fo
         icon = Theme::instance()->syncStateIcon(SyncResult::Problem);
     }
 
-    if (Progress::isSizeDependent(item._instruction)) {
+    if (Progress::isSizeDependent(item)) {
         columns << Utility::octetsToString( item._size );
     }
 
diff --git a/src/libsync/progressdispatcher.h b/src/libsync/progressdispatcher.h
index f286438..f4e657b 100644
--- a/src/libsync/progressdispatcher.h
+++ b/src/libsync/progressdispatcher.h
@@ -32,9 +32,12 @@ namespace OCC {
 namespace Progress
 {
     /** Return true is the size need to be taken in account in the total amount of time */
-    inline bool isSizeDependent(csync_instructions_e instruction) {
-        return instruction == CSYNC_INSTRUCTION_CONFLICT || instruction == CSYNC_INSTRUCTION_SYNC
-            || instruction == CSYNC_INSTRUCTION_NEW;
+    static inline bool isSizeDependent(const SyncFileItem & item)
+    {
+        return ! item._isDirectory && (
+               item._instruction == CSYNC_INSTRUCTION_CONFLICT
+            || item._instruction == CSYNC_INSTRUCTION_SYNC
+            || item._instruction == CSYNC_INSTRUCTION_NEW);
     }
 
 
@@ -50,7 +53,13 @@ namespace Progress
         quint64 _completedSize;
         // Should this be in a separate file?
         struct EtaEstimate {
-            EtaEstimate() :  _startedTime(QDateTime::currentMSecsSinceEpoch()), _agvEtaMSecs(0),_effectivProgressPerSec(0),_sampleCount(1) {}
+            EtaEstimate()
+                : _startedTime(QDateTime::currentMSecsSinceEpoch())
+                , _agvEtaMSecs(0)
+                , _effectivProgressPerSec(0)
+                , _sampleCount(1)
+            {
+            }
             
             static const int MAX_AVG_DIVIDER=60;
             static const int INITAL_WAIT_TIME=5;
@@ -115,11 +124,9 @@ namespace Progress
         void setProgressComplete(const SyncFileItem &item) {
             _currentItems.remove(item._file);
             _completedFileCount += item._affectedItems;
-            if (!item._isDirectory) {
-                if (Progress::isSizeDependent(item._instruction)) {
-                    _completedSize += item._size;
-                }
-            } 
+            if (Progress::isSizeDependent(item)) {
+                _completedSize += item._size;
+            }
             _lastCompletedItem = item;
             this->updateEstimation();
         }
@@ -142,7 +149,7 @@ namespace Progress
         quint64 completedSize() const {
             quint64 r = _completedSize;
             foreach(const ProgressItem &i, _currentItems) {
-                if (!i._item._isDirectory)
+                if (Progress::isSizeDependent(i._item))
                     r += i._completedSize;
             }
             return r;
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index ea46e83..ee15576 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -496,7 +496,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
 
     if (!item->_isDirectory) {
         _progressInfo._totalFileCount++;
-        if (Progress::isSizeDependent(file->instruction)) {
+        if (Progress::isSizeDependent(item)) {
             _progressInfo._totalSize += file->size;
         }
     } else if (file->instruction != CSYNC_INSTRUCTION_NONE) {

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