Skip to content

Commit

Permalink
Time estimation: Use a consistent check for size dependence. #2328
Browse files Browse the repository at this point in the history
  • Loading branch information
ckamm committed Apr 22, 2015
1 parent 509b83e commit 7d68c62
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/protocolwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
27 changes: 17 additions & 10 deletions src/libsync/progressdispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7d68c62

Please sign in to comment.