From 5cbcbdaa8f50ebca60077b55ce937739eab1fe1d Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Sun, 2 Jun 2024 01:58:56 +0200 Subject: [PATCH] Removing a domain: domain may not have tokens. --- Makefile | 2 +- src/storage.cr | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 6e34f25..63084cb 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ endif # No idea why, but I need that to run applications. Ignore that. #LD_P ?= LD_PRELOAD=/usr/local/lib/libipc.so.0 -OPTS ?= --progress --no-debug +OPTS ?= --progress Q ?= @ diff --git a/src/storage.cr b/src/storage.cr index 0dbf6ab..89b8754 100644 --- a/src/storage.cr +++ b/src/storage.cr @@ -334,12 +334,14 @@ class DNSManager::Storage return Response::DomainDeleted.new domain_name end - # Remove this domain_name from the list of user's domains. - domains_by_name.delete domain_name - # Remove the related zone and their registered tokens. zones_by_domain.delete domain_name - tokens_by_domain.delete domain_name + + # The domain may not have tokens. + tokens_by_domain.delete? domain_name + + # Remove this domain_name from the list of user's domains. + domains_by_name.delete domain_name Response::DomainDeleted.new domain_name end @@ -382,9 +384,10 @@ class DNSManager::Storage # Remove the user's domain when he is the only owner. if domain_cloned.owners.empty? - @domains_by_name.delete domain_cloned.name - @tokens_by_domain.delete domain_cloned.name - @zones_by_domain.delete domain_cloned.name + # The domain may not have tokens. + @tokens_by_domain.delete? domain_cloned.name + @zones_by_domain.delete domain_cloned.name + @domains_by_name.delete domain_cloned.name else @domains_by_name.update domain_cloned end