Fix error case in concurent transcode

This commit is contained in:
Zoe Roux 2024-01-12 01:20:10 +01:00
parent 68304af99e
commit 46cf60a3b9

View File

@ -1,6 +1,7 @@
package src package src
import ( import (
"errors"
"sync" "sync"
) )
@ -21,7 +22,11 @@ func (t *Transcoder) GetMaster(path string, client string) (string, error) {
t.mutex.RUnlock() t.mutex.RUnlock()
if preparing { if preparing {
stream = *<- t.channel pstream := <-t.channel
if pstream == nil {
return "", errors.New("could not transcode file. Try again later")
}
stream = *pstream
} else if !ok { } else if !ok {
t.mutex.Lock() t.mutex.Lock()
t.preparing[path] = true t.preparing[path] = true
@ -29,6 +34,11 @@ func (t *Transcoder) GetMaster(path string, client string) (string, error) {
stream, err := NewFileStream(path) stream, err := NewFileStream(path)
if err != nil { if err != nil {
t.mutex.Lock()
delete(t.preparing, path)
t.mutex.Unlock()
t.channel <- nil
return "", err return "", err
} }