Add a script to backfill the sizes of existing images.
This commit is contained in:
parent
e7904f0a9e
commit
623e2591e7
1 changed files with 16 additions and 0 deletions
16
tools/backfillsizes.py
Normal file
16
tools/backfillsizes.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
from data.database import Image
|
||||
from app import app
|
||||
|
||||
|
||||
store = app.config['STORAGE']
|
||||
|
||||
|
||||
for image in Image.select():
|
||||
if image.image_size == None:
|
||||
image_path = store.image_layer_path(image.repository.namespace,
|
||||
image.repository.name,
|
||||
image.docker_image_id)
|
||||
size = store.get_size(image_path)
|
||||
print 'Setting image %s size to: %s' % (image.docker_image_id, size)
|
||||
image.image_size = size
|
||||
image.save()
|
Reference in a new issue