Prevent a possible divide by 0 in obj/auditor.py.

Fixes bug 941731. If 'elapsed=0' in audit_all_objects set it
to 0.000001 to avoid divide by 0.

Change-Id: If0b43568033167818c482c8927863bea1dccfe57
This commit is contained in:
Doug Weimer 2012-02-27 02:35:50 +00:00
parent 6f7f95ffde
commit 72267260b1

View File

@ -105,7 +105,8 @@ class AuditorWorker(object):
self.errors = 0
self.bytes_processed = 0
time_auditing += (now - loop_time)
elapsed = time.time() - begin
# Avoid divide by zero during very short runs
elapsed = (time.time() - begin) or 0.000001
self.logger.info(_(
'Object audit (%(type)s) "%(mode)s" mode '
'completed: %(elapsed).02fs. Total quarantined: %(quars)d, '