fix(reader): persist chapter metadata cache to database

The DetectChapters function in reader.go was serializing chapter detection
results to JSON but then discarding the bytes with `_ = metadataBytes`
instead of writing them to the database. This meant chapter_metadata in
media_items was never populated, forcing re-detection on every request.

Replace the no-op discard with an actual UpdateMediaItemChapterMetadata()
call using the existing sqlc-generated query.
This commit is contained in:
2026-04-24 14:02:13 -04:00
parent da1732285f
commit d3ddecb840
+4 -3
View File
@@ -105,9 +105,10 @@ func (s *ReaderService) DetectChapters(ctx context.Context, mediaItemID uuid.UUI
metadataBytes, err := json.Marshal(result) metadataBytes, err := json.Marshal(result)
if err == nil { if err == nil {
// Update media item with chapter metadata _, _ = s.db.UpdateMediaItemChapterMetadata(ctx, database.UpdateMediaItemChapterMetadataParams{
// This would require a new query in database/queries.sql ID: pgtype.UUID{Bytes: mediaItemID, Valid: true},
_ = metadataBytes ChapterMetadata: metadataBytes,
})
} }
return chapters, nil return chapters, nil