Aug 25 - Fix inspection lost photos

This commit is contained in:
2026-08-25 09:40:20 -04:00
parent e31cd7e1ff
commit 3f30e2c7bd
4 changed files with 138 additions and 0 deletions
+25
View File
@@ -350,6 +350,31 @@ actor APIClient {
)
}
// Attach a late photo to an ALREADY-SUBMITTED inspection
// The inspection twin of updateIssuePhotos above, and the piece that was
// missing: an inspection photo that exhausted its upload attempts was
// submitted with its field blanked, and nothing could ever put it back.
// attachServerPath() wrote the recovered path into LOCAL form data only,
// so the server copy stayed empty forever even after a successful retry.
//
// Server-side (app/api/inspections.py, update_inspection) form_data is
// merged field-by-field via _merge_form_data: a non-empty incoming value
// wins, and existing 'uploads/...' paths are never blanked. Sending only
// the recovered fields is therefore safe and idempotent.
//
// `status` is deliberately NOT sent: including it would re-run the
// draftcompleted transition server-side, which is what fulfils a linked
// schedule. Omitting it leaves status, score and schedule untouched.
func updateInspectionFormData(inspectionId: Int,
fields: [String: String]) async throws {
struct R: Decodable, Sendable { let id: Int }
let _: R = try await request(
"/api/v1/inspections/\(inspectionId)",
method: "PATCH",
body: ["form_data": fields]
)
}
// Upload a resolution photo (entity_type = issue_result)
// Saves to issue_result_photos subfolder on the server same bucket
// as photos uploaded via the web update form.