Bug 1343718 - Don't display download progress when we don't know the download size in advance. r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 01 Mar 2017 11:16:27 +0900
changeset 353079 b5a3e4cb50908c4893bc9252cc19d9bf019ff04c
parent 353078 56cb728c5f74f50a164e18f30aa95f16eec3ac8b
child 353080 3717bedc62f9fb6b68dd8618ff2e70a02184428f
push id31656
push userihsiao@mozilla.com
push dateFri, 14 Apr 2017 09:10:41 +0000
treeherdermozilla-central@cda24082bff8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1343718
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1343718 - Don't display download progress when we don't know the download size in advance. r=chmanchester In most cases, the HTTP response for the download will contain the content-length, but if some error happens (e.g. authentication error), there might not be one, and the download fails with a TypeError for a division by None, instead of failing with a more friendly error message about the HTTP error.
python/mozbuild/mozbuild/artifacts.py
--- a/python/mozbuild/mozbuild/artifacts.py
+++ b/python/mozbuild/mozbuild/artifacts.py
@@ -713,16 +713,18 @@ class ArtifactCache(CacheManager):
 
         self.log(logging.INFO, 'artifact',
             {'path': path},
             'Downloading to temporary location {path}')
         try:
             dl = self._download_manager.download(url, fname)
 
             def download_progress(dl, bytes_so_far, total_size):
+                if not total_size:
+                    return
                 percent = (float(bytes_so_far) / total_size) * 100
                 now = int(percent / 5)
                 if now == self._last_dl_update:
                     return
                 self._last_dl_update = now
                 self.log(logging.INFO, 'artifact',
                          {'bytes_so_far': bytes_so_far, 'total_size': total_size, 'percent': percent},
                          'Downloading... {percent:02.1f} %')