diff --git a/app/models/users.py b/app/models/users.py index 38af1e5..1b7f4c9 100644 --- a/app/models/users.py +++ b/app/models/users.py @@ -214,8 +214,12 @@ class Member(User): db.session.commit() # Save the new avatar im.save(V5Config.AVATARS_FOLDER + self.avatar, 'PNG') - # If nothing has failed, remove old one - os.remove(old_avatar) + # If nothing has failed, remove old one (allow failure to regularize + # exceptional situations like missing avatar or folder migration) + try: + os.remove(old_avatar) + except FileNotFoundError: + pass def get_public_data(self): """ Returns the public information of the member."""