- Fix image size saving to occur before the return of the response

- Make the image size say ‘Unknown’ if it is not known
This commit is contained in:
Joseph Schorr 2014-01-03 16:42:38 -05:00
parent 0a63690e25
commit e7904f0a9e
2 changed files with 5 additions and 6 deletions

View file

@ -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)

View file

@ -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));