improved Modal with zoom and pagination. also implementing thumbnail generation
This commit is contained in:
+25
-3
@@ -1,9 +1,10 @@
|
||||
# image_import_loop.py
|
||||
# image_import_worker.py
|
||||
import time
|
||||
import os
|
||||
from app import create_app
|
||||
from app.utils.image_importer import import_images_task
|
||||
|
||||
THUMBNAIL_FLAG = "/import/thumbnail.flag"
|
||||
TRIGGER_FLAG = "/import/trigger.flag"
|
||||
SOURCE_DIR = "/import"
|
||||
DEST_DIR = "/images"
|
||||
@@ -29,8 +30,29 @@ def monitor_and_import():
|
||||
print("[Image Importer] Trigger flag cleared.")
|
||||
except Exception as e:
|
||||
print(f"[Image Importer] Failed to remove trigger flag: {e}")
|
||||
else:
|
||||
print("[Image Importer] No trigger flag. Sleeping...")
|
||||
|
||||
# Thumbnail generation Check
|
||||
if os.path.exists(THUMBNAIL_FLAG):
|
||||
print("[Image Importer] Thumbnail regeneration triggered.")
|
||||
try:
|
||||
from app.models import ImageRecord
|
||||
from app.utils.image_importer import generate_thumbnail
|
||||
|
||||
for img in ImageRecord.query.all():
|
||||
try:
|
||||
generate_thumbnail(img.filepath, overwrite=True)
|
||||
print(f"[Thumbnail] Regenerated for {img.filename}")
|
||||
except Exception as e:
|
||||
print(f"[Thumbnail] Failed for {img.filename}: {e}")
|
||||
except Exception as e:
|
||||
print(f"[Image Importer] Error during thumbnail regeneration: {e}")
|
||||
finally:
|
||||
try:
|
||||
os.remove(THUMBNAIL_FLAG)
|
||||
print("[Image Importer] Thumbnail flag cleared.")
|
||||
except Exception as e:
|
||||
print(f"[Image Importer] Failed to remove thumbnail flag: {e}")
|
||||
|
||||
|
||||
time.sleep(CHECK_INTERVAL)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user