Add code for saving and displaying the size of images

This commit is contained in:
Joseph Schorr 2014-01-03 16:32:00 -05:00
parent 8e4bbdf1dd
commit 0a63690e25
7 changed files with 42 additions and 0 deletions

View file

@ -125,7 +125,9 @@ 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()
tmp.seek(0)
csums.append(checksums.compute_tarsum(tmp, json_data))
tmp.close()
@ -148,6 +150,10 @@ 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)