This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/tools/uncompressedsize.py

31 lines
No EOL
929 B
Python

from data import model
from data.database import ImageStorage
from app import app, storage as store
import logging
def backfill_sizes():
count = ImageStorage.select().where(ImageStorage.uncompressed_size == None).count()
counter = 0
for image_storage in ImageStorage.select().where(ImageStorage.uncompressed_size == None):
logging.debug("Backfilling uncompressed size: %s of %s" % (counter, count))
# Lookup the JSON for the image.
uuid = image_storage.uuid
with_locations = model.get_storage_by_uuid(uuid)
json_data = store.get_content(with_locations.locations, store.image_json_path(uuid))
size = json_data.get('Size', None)
if size is None:
continue
image_storage.uncompressed_size = size
image_storage.save()
counter += 1
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('boto').setLevel(logging.CRITICAL)
backfill_sizes()