From ec9043dfecd8900aa1c38d02ee8034f9f1f811df Mon Sep 17 00:00:00 2001 From: David Brown Date: Fri, 25 Jan 2019 09:44:33 -0800 Subject: [PATCH] Make total_size some small number (#46) This initializes total_size of the bundle to some small number. This value is used as an estimate for the total size and the divisor in calculations so to prevent divide by zero errors. Signed-off-by: David Brown --- appveyor.yml | 1 + pacifica/uploader/bundler/bundler.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 20c6611..98c6437 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -70,6 +70,7 @@ install: python -m pip install pip setuptools wheel --upgrade; pip install -r requirements-dev.txt; pip install celery[redis] eventlet; + echo 'Done'; test_script: diff --git a/pacifica/uploader/bundler/bundler.py b/pacifica/uploader/bundler/bundler.py index 34a33cb..026baaf 100644 --- a/pacifica/uploader/bundler/bundler.py +++ b/pacifica/uploader/bundler/bundler.py @@ -82,11 +82,13 @@ def __init__(self, md_obj, file_data, **kwargs): self._hashstr = hashstr self._done_size = 0 self._complete = False - self._total_size = 0 + # this is an estimate of the total size and is used as a divisor + # to determine percent complete, so small number is okay + self._total_size = 0.0001 def _save_total_size(self): """Build the total size from the files and save the total.""" - tsize = 0 + tsize = 0.0001 for file_data in self.file_data: tsize += file_data['size'] self._total_size = tsize