Skip to content

Commit

Permalink
fix potential division by zero error
Browse files Browse the repository at this point in the history
  • Loading branch information
nil0x42 committed Sep 4, 2020
1 parent 6324c81 commit 00def6f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/status.c
Expand Up @@ -155,9 +155,9 @@ void display_status(void)
else if (!TAGDUP_TERMINATED())
{
percent_progression = 5.0;
if (g_status.done_ctasks > 0)
double tagdup_elapsed_time = elapsed_time - FCOPY_DURATION();
if (g_status.done_ctasks > 0 && tagdup_elapsed_time > 0.9)
{
double tagdup_elapsed_time = elapsed_time - FCOPY_DURATION();
double time_per_ctask = tagdup_elapsed_time / g_status.done_ctasks;
time_t remaining_time = time_per_ctask * MISSING_CTASKS();
/* adding FCOPY_DURATION because it's ~= FCLEAN_DURATION */
Expand All @@ -176,6 +176,7 @@ void display_status(void)
{
percent_progression = 95.0;


double percent_per_second = 5.0 / (double) FCOPY_DURATION();
time_t elapsed_fclean = current_time - g_status.fclean_date;
percent_progression += percent_per_second * (double)elapsed_fclean;
Expand Down

0 comments on commit 00def6f

Please sign in to comment.