"""Shared upload-path helper (Chapter 04) — used by the uploads blueprint, the optional CLI processor, and the automatic background-thread processor, so there's one definition of where a given LogFile's raw upload lives on disk. Pulled out of the uploads blueprint so services/ doesn't have to import from blueprints/ (the wrong direction) to reach it. """ from __future__ import annotations from pathlib import Path from flask import current_app from app.models.log_file import LogFile def upload_path_for(log_file: LogFile) -> Path: """Deterministic on-disk path for a LogFile row — avoids a new DB column.""" ext = Path(log_file.filename).suffix.lower() upload_dir = Path(current_app.config["UPLOAD_DIR"]) return upload_dir / f"{log_file.id}{ext}"