From 2651cbb374cef0c9c6b7fc4fd73637608df1e7b2 Mon Sep 17 00:00:00 2001 From: rr- Date: Sun, 19 Jun 2016 19:43:23 +0200 Subject: [PATCH] server/users: allow empty avatars if they existed --- server/szurubooru/func/users.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/szurubooru/func/users.py b/server/szurubooru/func/users.py index f625ebf..617b833 100644 --- a/server/szurubooru/func/users.py +++ b/server/szurubooru/func/users.py @@ -169,13 +169,16 @@ def update_user_avatar(user, avatar_style, avatar_content): user.avatar_style = user.AVATAR_GRAVATAR elif avatar_style == 'manual': user.avatar_style = user.AVATAR_MANUAL + avatar_path = 'avatars/' + user.name.lower() + '.png' if not avatar_content: + if files.has(avatar_path): + return raise InvalidAvatarError('Avatar content missing.') image = images.Image(avatar_content) image.resize_fill( int(config.config['thumbnails']['avatar_width']), int(config.config['thumbnails']['avatar_height'])) - files.save('avatars/' + user.name.lower() + '.png', image.to_png()) + files.save(avatar_path, image.to_png()) else: raise InvalidAvatarError( 'Avatar style %r is invalid. Valid avatar styles: %r.' % (