Fix the backfill script to handle images without any json data at all.

This commit is contained in:
Jake Moshenko 2014-09-24 10:42:42 -04:00
parent 48ed255a55
commit 6070c251ae

View file

@ -34,9 +34,13 @@ def backfill_sizes():
uuid = image_storage.uuid
with_locations = model.get_storage_by_uuid(uuid)
json_string = store.get_content(with_locations.locations, store.image_json_path(uuid))
json_data = json.loads(json_string)
size = json_data.get('Size', json_data.get('size', -1))
try:
json_string = store.get_content(with_locations.locations, store.image_json_path(uuid))
json_data = json.loads(json_string)
size = json_data.get('Size', json_data.get('size', -1))
except IOError:
logger.debug('Image storage with no json %s', uuid)
size = -1
if size == -1:
missing += 1