Progress: Don't count items without propagation jobs #4856 (#4910)
authorckamm <mail@ckamm.de>
Fri, 27 May 2016 08:52:00 +0000 (10:52 +0200)
committerckamm <mail@ckamm.de>
Fri, 27 May 2016 08:52:00 +0000 (10:52 +0200)
* 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

src/libsync/progressdispatcher.cpp

index 560c1ff8ba074915a11293234fcee92ae3a29d7e..3e9540a167504068c9658542eccc5591304cb414 100644 (file)
@@ -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);