Remove old profile pictures once new ones are set

This commit is contained in:
Kiril Kovachev 2024-10-21 10:20:35 +01:00
parent 009cb6aade
commit e00c9fe431

View File

@ -59,6 +59,10 @@ def create_app(test_config=None):
pfp = files["pfp"]
pfp.save(os.path.join(app.config["PFP_STORE"], stored_filename))
# Remove old PFP
if settings and settings["pfp"]:
os.remove(os.path.join(app.config["PFP_STORE"], stored_filename))
db.execute("UPDATE user_settings SET pfp_filename = ?", (stored_filename,))
db.commit()