Documentation
¶
Overview ¶
Package covers centralizes cover-file selection and serving so that the books, series, ereader, and OPDS handlers don't drift independently.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SelectFile ¶
SelectFile picks the file whose cover should represent a book based on the library's preferred cover aspect ratio. It always falls back across types when the preferred kind has no covers — a book-only library still gets a cover for an audiobook-only book, and vice versa. Supplements are excluded from selection regardless of cover state — they don't represent the book.
func ServeBookCover ¶
ServeBookCover selects the cover file from `files` using the library's preferred aspect ratio and serves it. Callers must perform any auth and library-access checks before calling. Returns errcodes.NotFound when no suitable cover exists or the cover image is missing on disk.
The cover is resolved via the file's parent directory rather than the book's filepath because book.Filepath can be a synthetic organized-folder path that never exists on disk for root-level books.
Conditional GET uses an ETag of `"<file_id>-<mtime_unix>"` and intentionally omits Last-Modified. SelectFile's choice depends on the library's CoverAspectRatio and which files belong to the book, so the served file's identity can change without any change to the new cover's mtime — flipping CoverAspectRatio on a hybrid book (EPUB + M4B) swaps which file's cover is served, and the new cover may have an older mtime than the previously-served one. Mtime-only revalidation would return stale 304s in that case; baking the file ID into the validator ensures it bumps whenever selection changes.
Types ¶
This section is empty.