From: ckamm Date: Fri, 27 May 2016 08:52:00 +0000 (+0200) Subject: Progress: Don't count items without propagation jobs #4856 (#4910) X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~1160^2~29 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b9fdae6d67e962b43d678d62f29c0021db346d9f;p=nextcloud-desktop.git Progress: Don't count items without propagation jobs #4856 (#4910) * Progress: Don't count dirs without propagation jobs #4856 These directory SyncFileItems are necessary for bookkeeping but should not influence the progress display at all. * Progress: Skip ignored files #4856 --- diff --git a/src/libsync/progressdispatcher.cpp b/src/libsync/progressdispatcher.cpp index 560c1ff8b..3e9540a16 100644 --- a/src/libsync/progressdispatcher.cpp +++ b/src/libsync/progressdispatcher.cpp @@ -155,16 +155,37 @@ bool ProgressInfo::isUpdatingEstimates() const return _updateEstimatesTimer.isActive(); } +static bool shouldCountProgress(const SyncFileItem &item) +{ + const auto instruction = item._instruction; + + // Don't worry about directories that won't have propagation + // jobs associated with them. + if (item._isDirectory + && (instruction == CSYNC_INSTRUCTION_NONE + || instruction == CSYNC_INSTRUCTION_SYNC + || instruction == CSYNC_INSTRUCTION_CONFLICT)) { + return false; + } + + // Skip any ignored or error files, we do nothing with them. + if (instruction == CSYNC_INSTRUCTION_IGNORE + || instruction == CSYNC_INSTRUCTION_ERROR) { + return false; + } + + return true; +} + void ProgressInfo::adjustTotalsForFile(const SyncFileItem &item) { - if (!item._isDirectory) { - _fileProgress._total++; - if (isSizeDependent(item)) { - _sizeProgress._total += item._size; - } - } else if (item._instruction != CSYNC_INSTRUCTION_NONE) { - // Added or removed directories certainly count. - _fileProgress._total++; + if (!shouldCountProgress(item)) { + return; + } + + _fileProgress._total += item._affectedItems; + if (isSizeDependent(item)) { + _sizeProgress._total += item._size; } } @@ -195,6 +216,10 @@ quint64 ProgressInfo::completedSize() const void ProgressInfo::setProgressComplete(const SyncFileItem &item) { + if (!shouldCountProgress(item)) { + return; + } + _currentItems.remove(item._file); _fileProgress.setCompleted(_fileProgress._completed + item._affectedItems); if (ProgressInfo::isSizeDependent(item)) { @@ -206,6 +231,10 @@ void ProgressInfo::setProgressComplete(const SyncFileItem &item) void ProgressInfo::setProgressItem(const SyncFileItem &item, quint64 completed) { + if (!shouldCountProgress(item)) { + return; + } + _currentItems[item._file]._item = item; _currentItems[item._file]._progress._total = item._size; _currentItems[item._file]._progress.setCompleted(completed);