Skip to content

Commit

Permalink
Only show the CLI time remaining for predictable status phases
Browse files Browse the repository at this point in the history
Fixes #4540
  • Loading branch information
hughsie authored and superm1 committed Apr 22, 2022
1 parent d599c90 commit ab0c750
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/fu-progressbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ fu_progressbar_erase_line(FuProgressbar *self)
g_print("\033[G");
}

static gboolean
_fu_status_is_predictable(FwupdStatus status)
{
if (status == FWUPD_STATUS_DEVICE_ERASE)
return TRUE;
if (status == FWUPD_STATUS_DEVICE_VERIFY)
return TRUE;
if (status == FWUPD_STATUS_DEVICE_READ)
return TRUE;
if (status == FWUPD_STATUS_DEVICE_WRITE)
return TRUE;
if (status == FWUPD_STATUS_DOWNLOADING)
return TRUE;
return FALSE;
}

static gboolean
fu_progressbar_estimate_ready(FuProgressbar *self, guint percentage)
{
Expand All @@ -116,6 +132,10 @@ fu_progressbar_estimate_ready(FuProgressbar *self, guint percentage)
return FALSE;
}

/* allow-list things that make sense... */
if (!_fu_status_is_predictable(self->status))
return FALSE;

old = self->last_estimate;
elapsed = g_timer_elapsed(self->time_elapsed, NULL);
self->last_estimate = elapsed / percentage * (100 - percentage);
Expand Down

0 comments on commit ab0c750

Please sign in to comment.