From d8b95abb39712a2783ed704b7be1324a38299777 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 6 May 2019 08:48:26 +0200 Subject: [PATCH] Check private key is true --- hosting/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hosting/models.py b/hosting/models.py index 616b036f..0ce4b140 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -213,8 +213,11 @@ class UserHostingKey(models.Model): return private_key, public_key def delete(self,*args,**kwargs): - if os.path.isfile(self.private_key.path): + if bool(self.private_key) and os.path.isfile(self.private_key.path): + logger.debug("Removing private key {}".format(self.private_key.path)) os.remove(self.private_key.path) + else: + logger.debug("No private_key to remove") super(UserHostingKey, self).delete(*args,**kwargs)