diff --git a/data/model/repository.py b/data/model/repository.py index 6709b3f09..46de62bf7 100644 --- a/data/model/repository.py +++ b/data/model/repository.py @@ -54,7 +54,10 @@ def purge_repository(namespace_name, repository_name): not need to be checked or responded to. """ - repo = _basequery.get_existing_repository(namespace_name, repository_name) + try: + repo = _basequery.get_existing_repository(namespace_name, repository_name) + except Repository.DoesNotExist: + return False # Delete all tags to allow gc to reclaim storage previously_referenced = tag.purge_all_tags(repo) @@ -74,7 +77,11 @@ def purge_repository(namespace_name, repository_name): return False # Delete the rest of the repository metadata - fetched = _basequery.get_existing_repository(namespace_name, repository_name) + try: + fetched = _basequery.get_existing_repository(namespace_name, repository_name) + except Repository.DoesNotExist: + return False + fetched.delete_instance(recursive=True, delete_nullable=False) return True