Jul 14 - Preparation for using CDN - fix issue

This commit is contained in:
2026-07-14 11:33:17 -04:00
parent 6c740772af
commit 42f9e4670c
2 changed files with 17 additions and 12 deletions
+3 -2
View File
@@ -1327,8 +1327,9 @@ timeout = 30
1. `Issue.photo_path` (string) 1. `Issue.photo_path` (string)
2. `Issue.mobile_photo_paths[]` (JSON list — iPad evidence) 2. `Issue.mobile_photo_paths[]` (JSON list — iPad evidence)
3. `Issue.result_photos[]` (JSON list — web resolution photos) 3. `Issue.result_photos[]` (JSON list — web resolution photos)
4. `Inspection.photo_path` (string) 4. `Inspection.form_data{}` — any `uploads/...` string (image fields; walk nested)
5. `Inspection.form_data{}` — any `uploads/...` string (image fields; walk nested) 5. `InspectionResult.photo_path` (string — per checklist-item result photo)
- `Inspection` itself has **no** `photo_path` column (the `photo_path` at inspection.py:103 belongs to `InspectionResult`, not `Inspection`).
- Signatures are inline `data:` base64 in the DB, **not files** → correctly ignored. - Signatures are inline `data:` base64 in the DB, **not files** → correctly ignored.
**Zero-loss invariants (non-negotiable):** **Zero-loss invariants (non-negotiable):**
+8 -4
View File
@@ -12,8 +12,8 @@ What it does
- Issue.photo_path (string) - Issue.photo_path (string)
- Issue.mobile_photo_paths[] (JSON list iPad evidence) - Issue.mobile_photo_paths[] (JSON list iPad evidence)
- Issue.result_photos[] (JSON list web resolution photos) - Issue.result_photos[] (JSON list web resolution photos)
- Inspection.photo_path (string)
- Inspection.form_data{} (any 'uploads/...' string, incl. nested image fields) - Inspection.form_data{} (any 'uploads/...' string, incl. nested image fields)
- InspectionResult.photo_path (string per checklist-item result photo)
(Signatures are stored inline as 'data:' base64, NOT files correctly ignored.) (Signatures are stored inline as 'data:' base64, NOT files correctly ignored.)
2. Checks each referenced path against the file actually on disk. 2. Checks each referenced path against the file actually on disk.
3. Walks the uploads tree and finds files NOT referenced by any record (orphans). 3. Walks the uploads tree and finds files NOT referenced by any record (orphans).
@@ -46,7 +46,7 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')
from app import create_app, db # noqa: E402 from app import create_app, db # noqa: E402
from app.models.issue import Issue # noqa: E402 from app.models.issue import Issue # noqa: E402
from app.models.inspection import Inspection # noqa: E402 from app.models.inspection import Inspection, InspectionResult # noqa: E402
# ── Path helpers ────────────────────────────────────────────────────────────── # ── Path helpers ──────────────────────────────────────────────────────────────
@@ -113,14 +113,18 @@ def collect_referenced():
for pth in (iss.result_photos or []): for pth in (iss.result_photos or []):
add(pth, f'issue:{iss.id}:result_photos', 'issue.result_photos') add(pth, f'issue:{iss.id}:result_photos', 'issue.result_photos')
# --- Inspections --- # --- Inspections: form_data image fields (Inspection has NO photo_path) ---
for insp in Inspection.query.yield_per(500): for insp in Inspection.query.yield_per(500):
add(insp.photo_path, f'inspection:{insp.id}:photo_path', 'inspection.photo_path')
fd = insp.form_data or {} fd = insp.form_data or {}
for s in walk_strings(fd): for s in walk_strings(fd):
# Any 'uploads/...' string inside form_data is an uploaded image value. # Any 'uploads/...' string inside form_data is an uploaded image value.
add(s, f'inspection:{insp.id}:form_data', 'inspection.form_data(image)') add(s, f'inspection:{insp.id}:form_data', 'inspection.form_data(image)')
# --- InspectionResult: per checklist-item result photo ---
for res in InspectionResult.query.yield_per(500):
add(res.photo_path, f'inspection_result:{res.id}:photo_path',
'inspection_result.photo_path')
return referenced, by_source return referenced, by_source