diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index a6858043a..ac195cc88 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 85e3f4102..0bccd81d2 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 f2864388d..f4e657b35 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 ea46e83ac..ee155765d 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) {