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:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user