diff --git a/app.py b/app.py index 79933b8..b56764a 100644 --- a/app.py +++ b/app.py @@ -114,6 +114,12 @@ def fetch_and_cache_profile_picture(user_id, avatar_url): local_image_path = os.path.join(PROFILE_IMAGE_DIR, f"{user_id}.png") + # Prüfen, ob das Bild bereits lokal gespeichert ist + if os.path.exists(local_image_path): + print(f"Profile picture for user {user_id} already exists locally.") + r.set(str(user_id), local_image_path) + return local_image_path + try: # Bild von der URL herunterladen und speichern response = requests.get(avatar_url, timeout=10) @@ -131,6 +137,7 @@ def fetch_and_cache_profile_picture(user_id, avatar_url): print(f"Error fetching profile picture for user {user_id}: {e}") return "/static/default_profile.png" + def get_profile_picture(user_id, avatar_url): """Versucht, das Profilbild eines Benutzers aus Redis, lokalem Speicher und zuletzt durch Download zu holen.""" # 1. Versuch: Redis