From 48af5d3e14abd6ba6efac2750eb6bd09e122d8c6 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 14 Aug 2026 08:26:14 -0400 Subject: [PATCH] feat(opds): always send X-Bookhoard-SHA256 on native EPUB downloads DownloadBook populated fileSha256 only for the kepub and pdf format branches, so the default EPUB download never emitted the X-Bookhoard-SHA256 response header - the hash was only available in the feed metadata, not on the download response itself. Populate it from mediaItem.FileSha256 in the default branch so every download response carries the canonical primary-format hash. Clients that capture response headers at download time now learn the hash regardless of which format they requested. --- internal/handlers/opds.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/handlers/opds.go b/internal/handlers/opds.go index 7b5d286..9b5d34b 100644 --- a/internal/handlers/opds.go +++ b/internal/handlers/opds.go @@ -605,6 +605,12 @@ func (h *OPDSHandler) DownloadBook(c *echo.Context) error { if mediaItem.MimeType.Valid { mimeType = mediaItem.MimeType.String } + // Always expose the primary content hash so clients (e.g. the koreader + // plugin) learn the canonical SHA-256 from the download response itself, + // not just from the feed metadata. + if mediaItem.FileSha256.Valid { + fileSha256 = mediaItem.FileSha256.String + } } // Check if file exists