diff options
| author | Dylan Bolger <dylan.bolger00@gmail.com> | 2026-08-18 11:50:09 -0500 |
|---|---|---|
| committer | Dylan Bolger <dylan.bolger00@gmail.com> | 2026-08-18 11:50:09 -0500 |
| commit | 2c3a67a823fe59df1aa910d0e8c82558ade84203 (patch) | |
| tree | 0d793fb93c6d6b69495b03b32ac0f35a94e20320 /app/services | |
| parent | 04892822306bf9a01de19cc70bcfc59d7fca9f8f (diff) | |
| download | photoblog-2c3a67a823fe59df1aa910d0e8c82558ade84203.tar.xz photoblog-2c3a67a823fe59df1aa910d0e8c82558ade84203.zip | |
kill image cache entirely
Diffstat (limited to 'app/services')
| -rw-r--r-- | app/services/images.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/app/services/images.py b/app/services/images.py index 4938014..f58b144 100644 --- a/app/services/images.py +++ b/app/services/images.py @@ -1,19 +1,14 @@ from pathlib import Path -from flask import Flask, current_app +from flask import Flask import random -image_cache = set() - -def cache_images(app: Flask): - photos_dir = Path(f"{app.static_folder}/photos") +def get_all_images(current_app: Flask): + images = [] + photos_dir = Path(f"{current_app.static_folder}/photos") for file_path in photos_dir.rglob("*"): if file_path.is_file(): - img_path = file_path.relative_to(app.static_folder) - image_cache.add(str(img_path)) - -def get_all_images(current_app: Flask): - # if not image_cache: - cache_images(current_app) - print(f"Returning {len(image_cache)} images") - shuffled = random.sample(list(image_cache), k=len(image_cache)) + img_path = file_path.relative_to(current_app.static_folder) + images.append(str(img_path)) + print(f"Returning {len(images)} images") + shuffled = random.sample(list(images), k=len(images)) return shuffled |
