diff --git a/internal/handlers/sidecar.go b/internal/handlers/sidecar.go index 3bd0f77..449c2d0 100644 --- a/internal/handlers/sidecar.go +++ b/internal/handlers/sidecar.go @@ -134,6 +134,21 @@ func (h *SidecarHandler) GetSidecarConfig(c *echo.Context) error { SHA256: item.FileSha256.String, FilePath: item.FilePath, } + + // Also key the book by each per-format hash (KEPUB/PDF/...), so a device + // holding a converted format resolves via the sidecar the same way it + // would via BookResolver on the server. + formats, ferr := h.db.GetMediaItemFormats(ctx, item.ID) + if ferr == nil { + entry := books[key] + for _, f := range formats { + if f.FileSha256.Valid && f.FileSha256.String != "" { + if _, exists := books[f.FileSha256.String]; !exists { + books[f.FileSha256.String] = entry + } + } + } + } } // Get collections @@ -269,6 +284,21 @@ func (h *SidecarHandler) DownloadSidecarConfig(c *echo.Context) error { SHA256: item.FileSha256.String, FilePath: item.FilePath, } + + // Also key the book by each per-format hash (KEPUB/PDF/...), so a device + // holding a converted format resolves via the sidecar the same way it + // would via BookResolver on the server. + formats, ferr := h.db.GetMediaItemFormats(ctx, item.ID) + if ferr == nil { + entry := books[key] + for _, f := range formats { + if f.FileSha256.Valid && f.FileSha256.String != "" { + if _, exists := books[f.FileSha256.String]; !exists { + books[f.FileSha256.String] = entry + } + } + } + } } // Get collections