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)
if err == nil {
// Update media item with chapter metadata
// This would require a new query in database/queries.sql
_ = metadataBytes
_, _ = s.db.UpdateMediaItemChapterMetadata(ctx, database.UpdateMediaItemChapterMetadataParams{
ID: pgtype.UUID{Bytes: mediaItemID, Valid: true},
ChapterMetadata: metadataBytes,
})
}
return chapters, nil