From 15879af5ce3bc5420ffd12ef6b0115e5f9a7d4fb Mon Sep 17 00:00:00 2001 From: Rafiq Hilali Date: Mon, 11 Feb 2019 17:12:11 +0000 Subject: [PATCH] fixed storage deletion bug --- avatar/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/avatar/models.py b/avatar/models.py index 5b836fc..0f080c0 100644 --- a/avatar/models.py +++ b/avatar/models.py @@ -210,7 +210,8 @@ def remove_avatar_images(instance=None, **kwargs): for size in settings.AVATAR_AUTO_GENERATE_SIZES: if instance.thumbnail_exists(size): instance.avatar.storage.delete(instance.avatar_name(size)) - instance.avatar.storage.delete(instance.avatar.name) + if instance.avatar.storage.exists(instance.avatar.name): + instance.avatar.storage.delete(instance.avatar.name) signals.post_save.connect(create_default_thumbnails, sender=Avatar)