mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 12:14:46 -04:00
Fix error case in concurent transcode
This commit is contained in:
parent
68304af99e
commit
46cf60a3b9
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user