From 2a89c2bb35f7c8fa4e47cf5f77bf1b38b2a262a7 Mon Sep 17 00:00:00 2001 From: yackob03 Date: Thu, 6 Feb 2014 14:22:13 -0500 Subject: [PATCH] Refactor the garbage collection code a tiny bit. --- data/model.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/data/model.py b/data/model.py index 336fc1f32..66cb37821 100644 --- a/data/model.py +++ b/data/model.py @@ -985,7 +985,9 @@ def garbage_collect_repository(namespace_name, repository_name): referenced_anscestors = set() for tag in tag_query: - ancestor_list = [int(img) for img in tag.image.ancestors.split('/')[1:-1]] + # The anscestor list is in the format '/1/2/3/', extract just the ids + anscestor_id_strings = tag.image.ancestors.split('/')[1:-1] + ancestor_list = [int(img_id_str) for img_id_str in anscestor_id_strings] referenced_anscestors = referenced_anscestors.union(set(ancestor_list)) referenced_anscestors.add(tag.image.id) @@ -999,8 +1001,8 @@ def garbage_collect_repository(namespace_name, repository_name): image_to_remove = all_images[image_id_to_remove] image_path = store.image_path(namespace_name, repository_name, image_to_remove.docker_image_id) - logger.debug('Recursively deleting image path: %s' % image_path) image_to_remove.delete_instance() + logger.debug('Deleting image storage: %s' % image_path) store.remove(image_path) return len(to_remove)