local: Ensure logging does not divide by zero in scanner.
This commit is contained in:
parent
6acd03995f
commit
316a1bf20f
@ -90,6 +90,7 @@ See :ref:`config` for general help on configuring Mopidy.
|
||||
|
||||
Number of tracks to wait before telling library it should try and store
|
||||
its progress so far. Some libraries might not respect this setting.
|
||||
Set this to zero to disable flushing.
|
||||
|
||||
.. confval:: local/excluded_file_extensions
|
||||
|
||||
|
||||
@ -144,10 +144,14 @@ class _Progress(object):
|
||||
|
||||
def increment(self):
|
||||
self.count += 1
|
||||
return self.count % self.batch_size == 0
|
||||
return self.batch_size and self.count % self.batch_size == 0
|
||||
|
||||
def log(self):
|
||||
duration = time.time() - self.start
|
||||
remainder = duration / self.count * (self.total - self.count)
|
||||
logger.info('Scanned %d of %d files in %ds, ~%ds left.',
|
||||
self.count, self.total, duration, remainder)
|
||||
if self.count >= self.total or not self.count:
|
||||
logger.info('Scanned %d of %d files in %ds.',
|
||||
self.count, self.total, duration)
|
||||
else:
|
||||
remainder = duration / self.count * (self.total - self.count)
|
||||
logger.info('Scanned %d of %d files in %ds, ~%ds left.',
|
||||
self.count, self.total, duration, remainder)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user