From e00c9fe43158c3fba663d00fbf2af4ab60b1afd3 Mon Sep 17 00:00:00 2001 From: Kiril Kovachev Date: Mon, 21 Oct 2024 10:20:35 +0100 Subject: [PATCH] Remove old profile pictures once new ones are set --- kanken_online/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kanken_online/__init__.py b/kanken_online/__init__.py index 4ae4c23..5925b6c 100644 --- a/kanken_online/__init__.py +++ b/kanken_online/__init__.py @@ -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()