From e7904f0a9e6df09588482b23fbd3560e914433f0 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 3 Jan 2014 16:42:38 -0500 Subject: [PATCH] =?UTF-8?q?-=20Fix=20image=20size=20saving=20to=20occur=20?= =?UTF-8?q?before=20the=20return=20of=20the=20response=20-=20Make=20the=20?= =?UTF-8?q?image=20size=20say=20=E2=80=98Unknown=E2=80=99=20if=20it=20is?= =?UTF-8?q?=20not=20known?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- endpoints/registry.py | 9 ++++----- static/js/app.js | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/endpoints/registry.py b/endpoints/registry.py index c2eb5334d..626dd171d 100644 --- a/endpoints/registry.py +++ b/endpoints/registry.py @@ -125,9 +125,12 @@ def put_image_layer(namespace, repository, image_id): sr.add_handler(sum_hndlr) store.stream_write(layer_path, sr) csums.append('sha256:{0}'.format(h.hexdigest())) - image_size = None try: image_size = tmp.tell() + + # Save the size of the image. + model.set_image_size(image_id, namespace, repository, image_size) + tmp.seek(0) csums.append(checksums.compute_tarsum(tmp, json_data)) tmp.close() @@ -150,10 +153,6 @@ def put_image_layer(namespace, repository, image_id): # Checksum is ok, we remove the marker store.remove(mark_path) - # Save the size of the image if we know it. - if image_size is not None: - model.set_image_size(image_id, namespace, repository, image_size) - # The layer is ready for download, send a job to the work queue to # process it. logger.debug('Queing diffs job for image: %s' % image_id) diff --git a/static/js/app.js b/static/js/app.js index 990825c70..4d0637924 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1027,7 +1027,7 @@ quayApp.directive('dockerAuthDialog', function () { quayApp.filter('bytes', function() { return function(bytes, precision) { - if (!bytes || isNaN(parseFloat(bytes)) || !isFinite(bytes)) return ''; + if (!bytes || isNaN(parseFloat(bytes)) || !isFinite(bytes)) return 'Unknown'; if (typeof precision === 'undefined') precision = 1; var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'], number = Math.floor(Math.log(bytes) / Math.log(1024));