[tracker/wip/passive-extraction] decorator: do not estimate remaining time when 0 elements have been processed



commit b50c3918e484e9d997cd25d8a60c08919328ad5d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jan 20 19:59:15 2014 +0100

    decorator: do not estimate remaining time when 0 elements have been processed
    
    >0 processed items are needed in order to estimate time, otherwise division by
    0 happens.

 src/libtracker-miner/tracker-decorator.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-decorator.c b/src/libtracker-miner/tracker-decorator.c
index 31de196..54985ed 100644
--- a/src/libtracker-miner/tracker-decorator.c
+++ b/src/libtracker-miner/tracker-decorator.c
@@ -197,8 +197,10 @@ decorator_update_state (TrackerDecorator *decorator,
                /* FIXME: Quite naive calculation */
                elapsed = g_timer_elapsed (priv->timer, NULL);
                elems_done = priv->stats_n_elems - priv->elem_queue->length;
-               remaining_time = (priv->elem_queue->length * elapsed) /
-                       elems_done;
+
+               if (elems_done > 0)
+                       remaining_time = (priv->elem_queue->length * elapsed) /
+                               elems_done;
        }
 
        g_object_set (decorator,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]