Check private key is true

This commit is contained in:
PCoder 2019-05-06 08:48:26 +02:00
parent 729a813804
commit d8b95abb39

View file

@ -213,8 +213,11 @@ class UserHostingKey(models.Model):
return private_key, public_key return private_key, public_key
def delete(self,*args,**kwargs): 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) os.remove(self.private_key.path)
else:
logger.debug("No private_key to remove")
super(UserHostingKey, self).delete(*args,**kwargs) super(UserHostingKey, self).delete(*args,**kwargs)