fix: Rezeptverlauf-Bilder lokal speichern und Windows-Subprocess-Fix

- Bilder beim Extrahieren lokal cachen (data/images/{id}.ext) und über GET /api/history/{id}/image ausliefern; Löschen bei Verlaufseintrag-Entfernung
- history.db in ./data/ Volume verschoben, damit sie Container-Rebuilds überlebt
- yt-dlp Subprocess-Aufrufe auf Windows gefixt: run_in_executor statt asyncio.create_subprocess_exec (SelectorEventLoop-Kompatibilität)
- ./data:/app/data Docker-Volume für persistente Datenhaltung hinzugefügt
This commit is contained in:
Andre
2026-04-14 17:17:03 +02:00
parent 4de67f0192
commit c7582dafbb
13 changed files with 125 additions and 33 deletions
+10 -1
View File
@@ -11,7 +11,7 @@ from app.config import get_settings
def _db_path() -> Path:
settings = get_settings()
return Path(settings.tmp_dir).parent / "history.db"
return Path(settings.images_dir).parent / "history.db"
def init_db() -> None:
@@ -73,6 +73,15 @@ def delete_recipe(history_id: int) -> None:
conn.commit()
def update_image_url(history_id: int, image_url: str) -> None:
with sqlite3.connect(_db_path()) as conn:
conn.execute(
"UPDATE recipe_history SET image_url = ? WHERE id = ?",
(image_url, history_id),
)
conn.commit()
def mark_imported(history_id: int, tandoor_recipe_id: Optional[int]) -> None:
now = datetime.now(timezone.utc).isoformat()
with sqlite3.connect(_db_path()) as conn: