feat: owner review 2 phase 3: Library on the web panel, photo trash and web upload (#11)
CI / Build and test (push) Successful in 7m25s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 10s
CI / PostgreSQL 16 integration (push) Successful in 5m20s
CI / PostgreSQL 17 integration (push) Successful in 5m22s
CI / Docker image (push) Successful in 50s
Release / Build, test and publish (push) Successful in 12m1s
Release / Server image (push) Successful in 1m26s
CI / Build and test (push) Successful in 7m25s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 10s
CI / PostgreSQL 16 integration (push) Successful in 5m20s
CI / PostgreSQL 17 integration (push) Successful in 5m22s
CI / Docker image (push) Successful in 50s
Release / Build, test and publish (push) Successful in 12m1s
Release / Server image (push) Successful in 1m26s
- Web panel Library: browse, view, delete sequences and photos, mass operations (analyse, proxies, thumbnails, verify, retag, delete, CSV). It never edits the video. - Photo trash with tombstones (migration 0008): crash-safe delete and restore, hash-checked restore with reasons, and emptying only by an explicit fingerprinted job. Sync and uploads keep deleted photos deleted; an explicit "Upload again" brings one back. - Upload from the web panel: in-house SHA-256 in a worker with a fail-closed self-test, capture time from EXIF, chunked, resumable; no folders. - Desktop trash dialog with photo entries and Empty. - Admin files are revalidated (no-cache + ETag). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #11.
This commit is contained in:
1 parent
af9eeaab9b
commit
9aa818ed47
283 files changed
+24922
-293
No files matched your search
@@ -473,3 +473,27 @@ One line per decision: date · decision · alternative · reason.
|
||||
| 2026-10-26 | `ServerSettingsDto` carries the log group as a nested `LogSettingsDto`; a `PUT` without it (an older panel) keeps the log settings, and saving applies them at once (`ServerLogging.Apply`). Desktop: Settings › Advanced gets six log rows, applied to the files at once and from the first log line of every launch (`AppLogging.Open`, also a launch that only hands over to the running Chronos), and Advanced gets a Reset section that restores them. (Owner review 2, R11.) | Flat DTO fields; apply the desktop's settings once the app has started | The group mirrors the panel's Logs group. The first line opens a file and prunes, so the defaults would delete what the user keeps longer. |
|
||||
| 2026-10-26 | Logging never fails what logs: `Log.Write` drops a line its sink throws on (anything but `OutOfMemoryException`), `TeeLogSink` isolates each sink, `FileLogSink` drops a line it cannot write (folder removed, disk full, file locked) and tries again at the next line without creating a removed folder again, and the server's `LoggerSink` drops the `AggregateException` Microsoft.Extensions.Logging throws. Before, an unwritable log left a failed job Running and could stop the job engine's worker and the scheduler's loop (seen as intermittent test failures). (Owner review 2, R10, R11.) | Let logging errors surface; create the folder again | Logging runs inside error handling (a job marked failed, a scheduler pass): the job's state and the next run matter more than a line. A removed log folder stays removed, its lines lost until the next start, rather than reappearing behind the user's back. |
|
||||
| 2026-10-26 | Setting a system schedule's age limit above 0 (Settings › Logs › Keep audit, or `CHRONOS_AUDIT_RETENTION_DAYS` at start) also ticks its default steps back on; while an environment variable fixes the age above 0, turning the schedule off, changing the age or unticking those steps is 409 `setting_locked`, and the panel disables those controls. The audit retention in force is 0 while the audit step is unticked. Keep audit and Jobs › Scheduled are last-writer-wins, like every panel setting. (Owner review 2, R10, R11.) | Leave the steps as edited; a separate lock per step | A limit set in Settings must take effect, and a variable's limit must not be undone from the panel. |
|
||||
| 2026-10-26 | Deleted photos go to `.chronos/trash/photos/<sequence id>-<yyyyMMddHHmmss>[-n]/originals/…` next to a `<name>.json` record: each photo's frame record, each file's former place, size and SHA-256, the sequence's title and folder, who deleted them, when, and the kind (`photos`, or `replaced` for a later conversion). An XMP companion goes with its photo when no photo that stays shares its name (listed once per folder, case-insensitively). The trash lists these entries as `photos-<folder>` beside the deleted sequences (`TrashKind` Sequence, Photos, Replaced). A deletion may name the frames version its photos were read at (refused with `frames_conflict` when the frames changed since) and is refused when every photo would go (`would_empty`). (Owner review 2, R6.) | Delete the files; flag the frames excluded; a trash in the index only | BRIEF §0.2 rule 8: nothing is erased until Empty, and the sidecars stay the truth. One listing serves restore and empty for both kinds; a sequence without photos is deleted whole, which keeps its settings and renders. |
|
||||
| 2026-10-26 | A photo deletion writes `remove.pending.json` in the sequence's `.chronos` before its first move, and its record as `<name>.json.pending`, which the trash never lists, restores or empties, until the sidecar is written. A failed move or sidecar write puts back what moved. A crash in between is settled by the next writer of the sequence (`SequenceWriter.ReadLocked`; also a scan and a sequence delete whenever a journal exists): while the sidecar still lists the frames, the files go back and the record and folder go (a file whose place is taken again stays, and its entry is then listed); otherwise the record takes its own name. Once the sidecar is written the deletion stands even if the index cannot follow (logged; the next scan resyncs it). (Owner review 2, R6.) | Publish the record first; change the index first | A crash never leaves a half-deleted sequence, nor half an entry that Restore or Empty could act on. |
|
||||
| 2026-10-26 | A restore into an existing sequence writes `restore.pending.json` before its first move and checks cancellation only before that. Another writer settles it under the sequence's lease and the entry's (taken with `TryAcquire`, owner `chronos@<machine>`): before the sidecar was written the files go back into the entry, after it the record drops the photos the sidecar lists. While the entry is busy (being emptied or restored) the journal stays, another restore into that sequence and the sequence's deletion are refused (`sequence_busy`), and scans do not reconcile it. A restore into a new sequence stages each original in `<entry>/.restoring/<path>` (never `.chronos/staging`, which maintenance sweeps), puts it back on any failure, checks cancellation only between photos and rewrites the record after each photo it files; the next restore of the entry first puts back what a crash left staged. Restore and Empty share the entry's lease `trash-<name>`. (Owner review 2, R6.) | One shared staging folder erased after the restore; no journal | Two restores of entries of one deleted sequence, maintenance and an emptying never touch each other's originals, and no step of a restore can lose one. |
|
||||
| 2026-10-26 | A restore re-hashes every file against its record. A photo stays in the trash with its reason when a file no longer matches (`mismatch`), when its files could not move (`not_moved`), when an intact frame of the sequence holds its content (`in_sequence`; a twin that is missing or damaged does not count, and the photo comes back as its own frame with its id) or when its original was missing at deletion (`no_file`); when no file matches, nothing moves (`TrashMismatchException`, 422 `trash_mismatch`). The others go back with the same frame records, by capture time, a name taken since getting `_2`, `_3`… with its companion following, and their tombstones go. When the sequence is gone the photos go into a new sequence through the ingest with the session key `trash:<sequence id>`, so every entry of that sequence joins one; a companion that cannot follow becomes a record leftover, counted, erased by Empty, never restored. A sequence entry goes back as its folder is, without hashing. The desktop and the API say the reasons (`keptReasons`, one sentence each). (Owner review 2, R6.) | Refuse when the sequence is gone; one sentence for every kept photo | Photos are never stranded, and the user learns why one stayed. |
|
||||
| 2026-10-26 | Tombstones are the sidecar's `removed` list (left out when empty, kept by older builds), copied into `frame_removals` (migration 0008) at every index sync without the content a frame of the sidecar holds again, and gone with the sequence row. A deletion writes one only for a SHA-256 no photo that stays holds. They outlive emptying the trash; a deleted sequence's record keeps them for a restore whose folder lost its sidecar, and a sidecar rebuilt from the photos takes the index's back. Filing that content into the sequence again (an import, a restore, an explicit upload again) drops its tombstone. (Owner review 2, R6.) | Tombstones in the index only, or in the trash records | A rebuild from the sidecars keeps them; a duplicate that stays was not removed; an emptied trash must not let sync bring the photo back. |
|
||||
| 2026-10-26 | Photos never hashed are hashed as they go, for their tombstone. Frames that stay are looked at only when never hashed and of a deleted photo's size: a SHA-256 of their first and last 64 KiB is compared first, the whole file is read only when those match, and the full hash is kept in the sidecar and the index. A dry run blocks a never-hashed original that is on disk but cannot be read (409 `photo_unreadable`; it opens at most 256 of them, and the deletion's own hashing refuses one past those as `folder_in_use`, nothing moved). Known limitation: a never-hashed photo whose original is already missing is deleted without a file and without a tombstone (its record stays, a restore reports `no_file`, Empty erases it), so a copy elsewhere can come back; the edge prints are not stored, so N such originals of one size cost 128 KiB × N reads per deletion until a verify hashes them. (Owner review 2, R6.) | Refuse to delete a photo without a hash; hash every frame that stays | A file that is gone has no content to name, and blocking it would make it undeletable; reading only likely twins keeps a deletion among raw files quick. |
|
||||
| 2026-10-26 | When indexed frames vanish from a sidecar (a deletion here, or by another process sharing the archive), `ProjectPositions` translates the project's positions by photo: those on the photos that went wait as pending frames and come back with a restore, the others follow their photos, and the settings version stays; a hero frame id whose frame is gone is cleared. A deletion or restore clears light and deep analysis, thumbnails and proxies in the sidecar and the row and queues them again: light analysis always, deep analysis at background priority when the sequence had one, thumbnails and proxies always on the server and on the desktop when it had them. Proxies are renamed and `thumbs.pack` re-keyed (`ThumbPackWriter.Rekey`, skipped while a thumbnail pass holds the pack) to follow their frames, and the server's thumbnail locator checks the fingerprint of never-hashed frames too. (Owner review 2, R6.) | Keep positions as they were (the earlier rule); rebuild every proxy and thumbnail | Exclusions, the hero and keyframes must not slide onto other photos; proxies and thumbnails are keyed by index, so moving them lets the passes reuse them and never shows a neighbour's thumbnail. |
|
||||
| 2026-10-26 | Emptying the trash is only an explicit job behind a dry run and a fingerprint. The dry run measures each entry on disk; the fingerprint is the SHA-256 of `kind\|name\|files\|bytes\|deletedAt ticks` per entry, in name order. The `EmptyTrash` job (stored as 18, user priority, normal level in the priority queue) keeps each entry's name and fingerprint: at its start any change of the plan erases nothing, a resumed job checks each remaining entry alone, and under its lease each entry is read and measured again and kept if it changed; an entry moves into `trash/.erasing` and is then deleted, leftovers going at the next emptying; a `replaced` entry goes only while its replacements still match their SHA-256 (re-hashed); a kept entry fails the job at the end. No schedule and no clean-up step empties the trash. The desktop asks for the number of entries to be typed, the panel for the word "empty" in its language. (Owner review 2, R6; BRIEF §0.2 rule 8.) | Erase in the request; a scheduled or age-based emptying | The only erase of user files must be an explicit, confirmed, verified and resumable action that erases exactly what the user saw. |
|
||||
| 2026-10-26 | Trash API under ManageArchive. Entry names are `<id>[-<time>[-n]]` (a sequence) or `photos-<id>-<time>[-n]`, and the API takes only that shape, never a path. Offline, the listing and the emptying answer 503 `archive_offline` (the erase also when read-only). 422 `trash_mismatch` is for an entry none of whose files matches its record, or a sequence entry whose own sidecar no longer names it; 409 `sidecar_mismatch` for a damaged or foreign sidecar of the sequence the photos return to (also on `frames/delete`, and on sequence deletes that settle a journal first). The emptying request is audited `trash_empty_requested` (entries, bytes, names, the job); what was erased is in the job's log. (Owner review 2, R6.) | Names with `/`; an empty listing when offline; audit `trash_emptied` at the request, or from the job | A single URL segment rules out path traversal; an unreachable archive is not an empty trash; an audit entry must not claim an erase the job may still refuse, and the job has no hook into the server's audit. |
|
||||
| 2026-10-26 | `POST /sequences/{id}/frames/delete` needs the Delete permission and the owner or an admin, like `DELETE /sequences/{id}`; each block has its code (`frames_conflict`, with the frames version now, only for changed frames; `sequence_busy`, `would_empty`, `photo_unreadable`, `archive_offline`), and it takes 1–100,000 ids under its own body limit (`FrameDeleteBodyLimit`, 100,000 × 48 + 4096 bytes, about 4.8 MB) set as routing metadata like the proxy route's: a third exception to the 2026-10-02 1 MiB rule, after chunks and proxies. (Owner review 2, R6.) | Lower the id limit to about 20,000 | A sequence of 100,000 photos must be able to lose most of them in one request; the 1 MiB limit stopped at about 26,900 ids. |
|
||||
| 2026-10-26 | Bulk routes take 1–1,000 distinct ids per request and answer each id in order, `ok` or `skipped` with the code and its sentence: delete moves each sequence whole as `DELETE /sequences/{id}` does (another user's is `forbidden` unless the caller is an admin), retag is the PATCH tag edit with up to 3 attempts on a conflict, and jobs queue one job at user priority. A verify of sequences targets their archive with the sequences in its parameters (`ArchiveJobs.Verify`), which also fixes `POST /jobs` with `verify`, whose job failed at once. The panel sends 1,000 ids a request (one job per 1,000 sequences, the toast counting them), lists every page of a filter for *Select all*, and refreshes every loaded row 1,000 a request. (Owner review 2, R6.) | No limit; a server-side "all of the filter" selection | Bounded requests and answers; the same rules as the single-sequence endpoints. |
|
||||
| 2026-10-26 | Uploads keep deleted photos out: a start whose SHA-256 the target sequence tombstoned answers `alreadyExists` without a frame id, unless a frame of the target still holds that content (a stale tombstone refuses no repair); the completion checks again after the upload stops receiving, and the ingest a third time under the sequence's lease, which a deletion takes (`IngestRequest.RefuseRemoved`), answering 409 `photo_removed` with the upload cancelled and its files deleted (`ChronosClient` returns null for it). Only an explicit user action brings such a photo back: `StartUploadRequest.Restore` and `complete?restore=true` (a query, so the uploads table needs no migration), sent by the panel's *Upload again* on a *Deleted before* row between runs, never by sync, the Uploader or a card import; with it no stand-in in another sequence counts, and filing the photo drops its tombstone, also after Empty. The desktop has no such path. (Owner review 2, R3, R6.) | Check at start only; store the flag on the upload; only a restore from the trash brings a photo back | An old client syncing a copy, or a watch folder, must not undo a deletion, and no deletion may land between the last check and the commit; a user who uploads a photo again on purpose means it, also once the trash is emptied. |
|
||||
| 2026-10-26 | Sync tombstones: a `deleted` tombstone keeps the photo from being offered to the side that deleted it (no upload of what the server deleted, no download of what this PC deleted); a `replaced` one is an alias, followed up to 8 steps, compared, transferred and translated as the replacement. A tombstone leaves a photo out only while its side holds no matching photo (by hash, or by size and capture time while unhashed). An unhashed server frame is fetched, hashed and dropped when this PC deleted it; an unhashed local frame the server deleted is not sent, and the archive verify then runs so the next comparison leaves it out. Positions parked for a photo the other copy deleted stay pending; sync never deletes local files. Known limitation: until the server verifies such a frame, the row counts it as missing here and *Download* fetches and drops it each time (fixing it needs size and capture time in the tombstones). (Owner review 2, R6.) | Drop parked positions; delete the local copy; tombstones by size and time now | A deletion on one side is not undone by the other, neither side loses a file, and a restore places the parked positions again. |
|
||||
| 2026-10-26 | The server refuses frame uploads whose file name starts with `.` (400 `invalid_file_name`) from every client, and the panel's dialog counts such files as not photos. (Owner review 2, R3.) | Leave them to each client | The archive scanner leaves hidden files out, so an upload must not file what an import of the same folder would not; the AppleDouble `._` files a Mac leaves on cards were filed through the server import before. |
|
||||
| 2026-10-26 | The panel's Library is the second sidebar entry, with the Image icon (the Dashboard keeps the four tiles of the mockup). The trash is a view of the Library (`#/library?view=trash`, `pages/library/trash.js`) that Archive opens with a *Trash* button. The upload dialog is a module the Library and a sequence import on demand (`import("../upload.js")`, exporting `openUpload({ api, sequence, onDone })`); a test checks that nothing imports it statically and, lexing every admin module, that each top-level function that uses `api` takes it. (Owner review 2, R6, R3.) | A Trash panel inside Archive; static imports | One route and module reachable from both places, beside the deletions that fill it; other pages never load the upload code; CI has no JavaScript engine, so a structural check catches an out-of-scope `api` like the one that broke every web upload during this phase. |
|
||||
| 2026-10-26 | New `GET /api/v1/sequences/facets` (years newest first, camera models most used first with `PathTemplate.CameraName` as their label, tags by key with their first spelling, each with its count, from the server archive's rows) and `rendered=true\|false` on `GET /sequences`. Covers come from `GET /sequences/{id}/thumb` (the hero's thumbnail, else the first frame's; `private, max-age=3600`, ETag) at `?v=<hero>-<framesVersion>`. (Owner review 2, R6.) | Menus built from the loaded page; no cover endpoint | The menus must offer exactly the values the filters take without reading every sequence; a new cover or other photos change the address, while edits of title, tags or rating keep the cached image. |
|
||||
| 2026-10-26 | Panel confirmations: deleting photos asks for their number to be typed when more than 20 go; emptying the trash asks for the localised word "empty" (any case); moving sequences to the trash asks for nothing typed, its dialog listing at most 500 names, the blocked first with why. CSV export is built in the browser from the sequences the page knows (the selection, or all of the filter after *Select all*): ISO dates as recorded, bytes, localised headers, and a cell starting with `=`, `+`, `-`, `@`, tab or CR prefixed with an apostrophe. Selectable grids (cards, list rows, photos) are listboxes with one tab stop; the photo grid stays left to right in right-to-left languages. (Owner review 2, R6.) | A typed confirmation everywhere; a server CSV endpoint | Moving to the trash is undone by Restore, erasing is not; typing a count makes a large deletion's size read; a word is checked the same way in every language; a CSV must be safe to open in a spreadsheet; hundreds of tab stops would make the keyboard useless. |
|
||||
| 2026-10-26 | The panel's pages follow `sequenceChanged` and `jobState`. `jobState` carries no job kind or target, so a sequence page reads itself and its renders after any job ends (at most every 1.5 s) and redraws only what changed, keeping the focus; thumbnails not built yet are asked again from 2 s up to 60 s apart, 8 times at most. After the WebSocket reconnects, `api.events` gives the page a client-only `{ type: "reconnected" }`, on which the trash reads the emptying it follows again (`GET /jobs/{id}`; a job no longer listed is dropped). (Owner review 2, R6.) | Add kind and targets to `jobState` now; refresh on every event | No protocol change in this phase, and archive-wide jobs change every sequence anyway; events lost during a reconnect must not leave Empty disabled. |
|
||||
| 2026-10-26 | The admin panel's files are served with `Cache-Control: no-cache` and their content ETag; `If-None-Match` honours lists, weak `W/` tags and `*`, and an unchanged file answers 304. (Owner review 2, R6.) | `public, max-age=3600` (before); versioned module addresses | With an hour of cache, a browser that loaded the panel before an upgrade could run new modules next to old ones; revalidation sends again only what the upgrade changed, with no build step. |
|
||||
| 2026-10-26 | The web upload hashes with an in-house incremental SHA-256 (`sha256.js`, FIPS 180-4, `Int32Array`, update/digest) in a same-origin module worker (`hash-worker.js`) that reads `file.slice()` in 8 MiB blocks and reports progress. The CSP is unchanged: the panel's policy has no `worker-src` or `child-src`, so the worker falls under `script-src 'self'`, which a test pins. About 120 MB/s under V8 (node 24). (Owner review 2, R3.) | `crypto.subtle.digest`; a JavaScript library | `crypto.subtle` digests one whole buffer, so a large RAW would sit in memory, and the rules allow no third-party code; hashing off the page's thread keeps the dialog responsive. |
|
||||
| 2026-10-26 | The browser's SHA-256 self-tests and fails closed: before its first hash each worker runs the FIPS 180-4 known answers (the empty message, "abc", the 448- and 896-bit messages, one million "a"), whole and fed in uneven pieces, and where `crypto.subtle` exists compares a 1 MiB random buffer with it; on any mismatch every hash is refused and the dialog says so and uploads nothing. The server still verifies every upload. CI has no JavaScript engine, so the vectors, 300 random lengths against `node:crypto` and deliberately broken copies were run once with node 24. (Owner review 2, R3.) | Trust the implementation; let the server's 422 catch a wrong hash | A wrong hash would be refused only after the whole file was sent, and a browser engine fault would fail every upload one by one. |
|
||||
| 2026-10-26 | No folder upload on the web panel: the dialog has no `webkitdirectory` or directory picker (a test checks), and folders dropped on it are detected with `webkitGetAsEntry`, counted as *Folders skipped* and left out. Only files whose extension `server/info` lists (the new optional `extensions`, from `ImageFormatInfo.Known`, the scanner's list), not empty and within `limits.maxUploadBytes`, are taken. (Owner review 2, R3, R9.) | Upload folders; a list of extensions in JavaScript | The owner's request: importing a whole folder stays on the desktop. A copy of the list would drift, and the archive would ignore files that are not photos. |
|
||||
| 2026-10-26 | Web upload pacing: two photos and two chunks per photo at once (four of the server's eight chunks per account); a call with no answer, 429 or 503 retried after 1, 2 and 4 s; 401, 403, 507, an unknown target (404 `sequence`) and a failed self-test stop the remaining photos (*Not sent*) with the server's message; a completion refused with 409 `upload_state` is read again after 1, 2, 4 and then every 8 s, about a minute; two copies of one photo in a run go one after the other. A new target is created by one `POST /sequences`, never retried, and stays the dialog's target. Each start carries the capture time: the Exif DateTimeOriginal of a JPEG or TIFF-based file (from its first 256 KiB, every offset checked), else the file's modification time as local wall time, which the ingest uses only for a photo with no time of its own. (Owner review 2, R3.) | Send everything at once; `capturedAt` null | Room for the user's other clients; a refusal that would refuse every photo stops at once; a lost answer must not create two sequences; photos without Exif keep their order instead of taking their arrival time. |
|
||||
| 2026-10-26 | Cancel deletes, Close keeps: Cancel aborts the requests, stops the worker and deletes the uploads the run started and did not complete; an upload that failed otherwise (507 at completion, say) stays receiving and the next run resumes it (same user, hash, size and sequence), abandoned ones expiring after the upload retention. During a run Esc is held by a capture-phase listener on the document and leaving the page asks first, so only Cancel stops it. (Owner review 2, R3.) | Delete every unfinished upload on Close; let Esc close the dialog | Cancel frees the space at once; a failure the user can fix is resumed without sending the photo again; a stray Esc must not discard uploads. |
|
||||
Reference in new issue
Block a user