mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 08:21:39 -06:00
17aa7425f8
* feat(scanner): set book added_at from earliest on-disk file mtime A book's "date added" now reflects when its content files first landed on disk (the earliest mtime across its content-role files) instead of the moment BookOrbit imported it. Cover/metadata/supplement sidecars are excluded. When no content file has a usable mtime, addedAt is left unset so the DB defaultNow() fallback (import time) still applies. Only set at initial book creation; re-scan/restore paths do not touch it. * feat(library): add per-library added_at source with recompute Add an addedAtSource setting to libraries so "date added" can follow the book's files on disk rather than the moment the scanner happened to see them. The setting takes imported (unchanged default), file_modified, or file_created, guarded by a check constraint on the column. Expose a recompute action so the chosen source can be applied to books that are already imported. file_modified runs as a single set-based update over the stored mtimes; file_created has to stat the files, since birthtime is not persisted, so it batches those reads. Leave every existing library on imported so behavior is unchanged unless a user opts in. * feat(library): add added_at source control to the library editor Surface the new addedAtSource setting in the library editor as a radio group, alongside a button that triggers the recompute for the library being edited. Keep the recompute out of the save path so changing the setting stays cheap: the setting alone only affects books imported from then on, and applying it to existing books is an explicit choice. * i18n(library): translate added_at source strings (de/nl/pt/sl) * fix(library): correct create payload, recompute floor and failure logging The library creator posts its whole form, so omitting addedAtSource from CreateLibraryDto made the global whitelist reject every create request with a 400. Declare the field, validate it against the same source list as the update DTO, and persist it so the initial scan uses the requested source rather than silently falling back to imported. Apply the scanner's usable-time floor to the mtime recompute query too. It previously excluded only NULL, so a filesystem reporting epoch 0 would rewrite added_at to 1970 instead of leaving the import time in place. The floor now lives in library.constants rather than being spelled out twice. Wrap the recompute in try/catch so a database or stat failure emits the [fail] log the logging conventions require instead of propagating with only a [start] line recorded. * fix(library): gate recompute on the saved source and label the radios The recompute button stayed enabled while the selected source differed from the stored one. Because the request carries no source, clicking it recomputed against the old stored value while the UI showed the new selection. A hint already said to save first; disable the control as well so the mismatch is not actionable. Give the source list radiogroup semantics with aria-checked so screen readers can tell which option is active, since selection was conveyed by styling alone. * test(library): assert the create DTO under the real validation options The previous comment claimed the case exercised whitelist and forbidNonWhitelisted, but the shared helper calls validate without them, so it only proved @IsIn rejects an unknown value. Drop the misleading comment and add a case that validates with the same options main.ts gives ValidationPipe, so an undeclared addedAtSource fails the way it would in a real request. * docs(library): remove redundant date-added documentation --------- Co-authored-by: Bob Bobber <user@example.com> Co-authored-by: neon <18559658+neonsolstice@users.noreply.github.com>