from __future__ import annotations from app.core.config import settings def document_storage_statistics() -> dict[str, int | float]: root = settings.upload_path used_bytes = 0 if root.exists(): for path in root.rglob("*"): try: if path.is_file(): used_bytes += path.stat().st_size except OSError: continue capacity_bytes = max( 1, int(float(settings.storage_capacity_gb) * 1024**3), ) usage_percent = min(used_bytes / capacity_bytes * 100, 100.0) return { "storage_used_bytes": used_bytes, "storage_capacity_bytes": capacity_bytes, "storage_usage_percent": round(usage_percent, 1), }