Remove former profile image upon new upload (#381)

* Remove former profile image upon new upload

* Fix test
This commit is contained in:
sephrat
2021-05-01 23:35:46 +02:00
committed by GitHub
parent fad2f8da59
commit 52e5e9da5d
5 changed files with 32 additions and 6 deletions

View File

@@ -105,10 +105,7 @@ async def update_user_image(
app_dirs.USER_DIR.joinpath(id).mkdir(parents=True, exist_ok=True)
try:
[x.unlink() for x in app_dirs.USER_DIR.join(id).glob("profile_image.*")]
except Exception:
pass
[x.unlink() for x in app_dirs.USER_DIR.joinpath(id).glob("profile_image.*")]
dest = app_dirs.USER_DIR.joinpath(id, f"profile_image.{extension}")