From 86636b2eb73a0bdab61403c5df19873d71498e8e Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Fri, 27 Nov 2020 16:36:05 +0100 Subject: [PATCH] fix delete user profile picture --- app/api/views/user_info.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/api/views/user_info.py b/app/api/views/user_info.py index f42d7f6d..e5d3c367 100644 --- a/app/api/views/user_info.py +++ b/app/api/views/user_info.py @@ -54,11 +54,12 @@ def update_user_info(): if "profile_picture" in data: if data["profile_picture"] is None: if user.profile_picture_id: + user.profile_picture_id = None + db.session.flush() + file = user.profile_picture File.delete(file.id) s3.delete(file.path) - - user.profile_picture_id = None else: raw_data = base64.decodebytes(data["profile_picture"].encode()) file_path = random_string(30)