Fix subtitle extraction race condition

This commit is contained in:
Zoe Roux 2025-10-12 18:01:04 +02:00
parent e348464261
commit b7c6ba1e85
No known key found for this signature in database
3 changed files with 6 additions and 6 deletions

View File

@ -45,10 +45,6 @@ func (h *mhandler) GetInfo(c echo.Context) error {
if err != nil {
return err
}
err = ret.SearchExternalSubtitles()
if err != nil {
fmt.Printf("Couldn't find external subtitles: %v", err)
}
return c.JSON(http.StatusOK, ret)
}

View File

@ -16,7 +16,7 @@ import (
const ExtractVersion = 1
func (s *MetadataService) ExtractSubs(ctx context.Context, info *MediaInfo) (interface{}, error) {
func (s *MetadataService) ExtractSubs(ctx context.Context, info *MediaInfo) (any, error) {
get_running, set := s.extractLock.Start(info.Sha)
if get_running != nil {
return get_running()

View File

@ -241,7 +241,7 @@ func (s *MetadataService) getMetadata(path string, sha string) (*MediaInfo, erro
}
rows, err = s.database.Query(
`select s.idx, s.title, s.language, s.codec, s.mime_codec s.extension, s.is_default, s.is_forced, s.is_hearing_impaired
`select s.idx, s.title, s.language, s.codec, s.mime_codec, s.extension, s.is_default, s.is_forced, s.is_hearing_impaired
from subtitles as s where s.sha=$1`,
sha,
)
@ -265,6 +265,10 @@ func (s *MetadataService) getMetadata(path string, sha string) (*MediaInfo, erro
}
ret.Subtitles = append(ret.Subtitles, s)
}
err = ret.SearchExternalSubtitles()
if err != nil {
fmt.Printf("Couldn't find external subtitles: %v", err)
}
rows, err = s.database.Query(
`select c.start_time, c.end_time, c.name, c.type