Harden: cap request body before reading, WAL for concurrent writes, socket timeout, surface unmeasured edges

- _body() read the full declared Content-Length into memory before any size
  check, so MAX_UPLOAD_BYTES could only reject an upload already held in
  RAM. nginx caps this on the proxied path, but the container also listens
  on the LAN, so the app now enforces its own 20MB ceiling and closes the
  connection rather than reading.
- SQLite ran with the default rollback journal and 5s lock timeout, chosen
  when a row was a few KB; rows now carry the original photos, so two
  people grading at once could block each other's History. WAL + 30s.
- No socket timeout meant a stalled keep-alive connection held a worker
  thread indefinitely.
- An edge excluded as a different material was dropped from the UI with no
  explanation, presenting three sides as though they were all four.
This commit is contained in:
Barely Removable 2026-08-22 12:56:58 -07:00
parent f8db3df605
commit 3270a9fe69
3 changed files with 75 additions and 5 deletions

View file

@ -131,9 +131,19 @@ function renderGradeBlock(g, opts = {}) {
if (m && m.reliable === false) {
measuredLine = `not measurable — ${m.reason || "this card's finish"}`;
} else if (m && m.edges) {
measuredLine = ['top', 'right', 'bottom', 'left']
const sides = ['top', 'right', 'bottom', 'left'];
measuredLine = sides
.filter((s) => m.edges[s])
.map((s) => `${s} ${m.edges[s].percent.toFixed(0)}%`).join(' · ');
// An edge excluded for reading as a different material (a die-cut clear
// window, a foil strip) comes back with no score. Listing only the
// edges that DID measure would quietly present three sides as if they
// were all four — say which one is missing and why.
const skipped = sides.filter((s) => !m.edges[s] && (m.edge_notes || {})[s]);
if (skipped.length) {
const why = m.edge_notes[skipped[0]];
measuredLine += `${measuredLine ? '; ' : ''}${skipped.join(' and ')} not measured — ${why}`;
}
}
const cm = g.centering_measurement || null;