diff --git a/ipynbsrv/core/signals/container_images.py b/ipynbsrv/core/signals/container_images.py index 16dcc8b..690779e 100644 --- a/ipynbsrv/core/signals/container_images.py +++ b/ipynbsrv/core/signals/container_images.py @@ -22,20 +22,6 @@ def create_image_on_server(sender, container, image, **kwargs): raise ex -@receiver(container_deleted) -def delete_internal_image_if_latest(sender, container, **kwargs): - """ - Delete the internal only image if this is the last container using it. - """ - if container is not None: - try: - if container.is_image_based() and container.image.is_internal and not container.has_clones(): - if not Container.objects.filter(image=container.image).exists(): - container.image.delete() - except ContainerImage.DoesNotExist: - pass - - @receiver(container_image_deleted) def delete_related_notifications(sender, image, **kwargs): """ diff --git a/ipynbsrv/core/signals/containers.py b/ipynbsrv/core/signals/containers.py index 8350324..a6329fe 100644 --- a/ipynbsrv/core/signals/containers.py +++ b/ipynbsrv/core/signals/containers.py @@ -146,6 +146,10 @@ def delete_on_server(sender, container, **kwargs): if container is not None: try: container.server.get_container_backend().delete_container(container.backend_pk) + # cleanup internal images + if container.is_image_based() and container.image.is_internal and not container.has_clones(): + if not Container.objects.filter(image=container.image).exists(): + container.image.delete() except ContainerNotFoundError as ex: pass # already deleted except ContainerBackendError as ex: