Handle done events with no actual files done

This commit is contained in:
Kovid Goyal 2022-06-26 10:43:43 +05:30
parent f9b6a39b2a
commit f77b3e778a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -56,12 +56,15 @@ class IndexingProgress:
return _('almost done') return _('almost done')
if len(self.done_events) < 5: if len(self.done_events) < 5:
return _('calculating time left') return _('calculating time left')
start_time = self.done_events[0][1] try:
end_time = self.done_events[-1][1] start_time = self.done_events[0][1]
num_done = sum(x[0] for x in self.done_events) - self.done_events[0][0] end_time = self.done_events[-1][1]
rate = num_done / max(0.1, end_time - start_time) num_done = sum(x[0] for x in self.done_events) - self.done_events[0][0]
seconds_left = self.left / rate rate = num_done / max(0.1, end_time - start_time)
return _('~{} left').format(human_readable_interval(seconds_left)) seconds_left = self.left / rate
return _('~{} left').format(human_readable_interval(seconds_left))
except Exception:
return _('calculating time left')
class ScanProgress(QWidget): class ScanProgress(QWidget):