WIP: feat(admin): bake metadata into source files on disk#39
Open
bndct-devops wants to merge 1 commit into
Open
WIP: feat(admin): bake metadata into source files on disk#39bndct-devops wants to merge 1 commit into
bndct-devops wants to merge 1 commit into
Conversation
Add an admin "Bake to File" tool that writes Tome's metadata (title, author, series, description, cover, tags) directly into the library files on disk, complementing the existing lazy download-time cache. Useful when files are read outside Tome (Syncthing, Calibre, NAS). Runs as a single serial, cancellable background job with byte-weighted progress + ETA; it survives a tab close and the page reconnects to a running job on return. Per-file safety: validate the embed parses -> atomic tmp write + os.replace -> recompute sha256 -> set BookFile.metadata_synced_at. get_baked_path() serves the raw file once synced, so re-runs skip already-current files and a restart resumes. Disabled on read-only mounts; TOME_ALLOW_INFILE_BAKE is a hard off-switch. CBZ pages are stored uncompressed during embed to cut bake time on large comic archives. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an admin Bake to File tool that writes Tome's metadata — title, author, series, description, cover, tags — directly into the source library files on disk, complementing the existing lazy download-time cache (
get_baked_path, which stays). Useful when files are consumed outside Tome: Syncthing to another device, a Calibre library on the same folder, or direct NAS browsing.How it works
backend/services/bake_job.py): single, serial, cancellable, in-memory. Runs in a daemon thread so it survives the request — closing the tab or navigating away doesn't stop it, and the page reconnects to a running job by pollingGET /api/admin/bake/status.metadata_embed.bake_to_file): validate the embed parses → write sibling.bake.tmp→ fsync → atomicos.replace→ recompute sha256 → setBookFile.metadata_synced_at = book.updated_at. A bad embed never clobbers the source; one bad file never aborts the run.metadata_synced_at == updated_atmakesget_baked_path()serve the raw file and makes re-runs skip already-current files (a server restart just resumes).library_writable()), andTOME_ALLOW_INFILE_BAKE(defaulttrue) as a hard off-switch._compress_for) — the main bake-time win on large comic archives.EPUB/CBZ get full metadata + cover; PDF gets title/author/subject.
Endpoints
GET /api/admin/bake/{status,preflight},POST /api/admin/bake/{start,cancel,dismiss}— all admin-gated; start is audited.Migration
Additive
BookFile.metadata_synced_atcolumn via the lifespanALTER TABLEpattern (NULL for all existing rows).Testing
tests/test_bake_to_file.py(10): EPUB/CBZ happy paths, hash recompute,metadata_synced_atsemantics +get_baked_pathearly-return, read-only guard, corrupt/raising embed leaves the original intact with no leftover.tmp, CBZ stored-not-deflated, skips.npm run buildclean..tmp, all files valid, OPFs rewritten withcalibre:series.