mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-12-27 07:10:25 -05:00
Fix subtitle extraction race condition
This commit is contained in:
parent
e348464261
commit
b7c6ba1e85
@ -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)
|
||||
}
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user