Retry random track, better error reporting
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f9d5cb11ec
commit
37be61a27e
29
api.go
29
api.go
|
@ -112,18 +112,25 @@ func (a *API) handleQueue() {
|
|||
defer close(a.queue.QueueEmpty)
|
||||
//TODO: close properly
|
||||
for {
|
||||
if e, err := a.getRandomTrack(); e != nil {
|
||||
//preload
|
||||
if err = e.Load(); err != nil {
|
||||
log.Printf("random track loading error for %s: \"%s\"", e.Path, err)
|
||||
continue
|
||||
failed := true
|
||||
//give three tries for a random track to succeed
|
||||
for i := 0; i < 3; i++ {
|
||||
if e, err := a.getRandomTrack(); e != nil {
|
||||
//preload
|
||||
if err = e.Load(); err != nil {
|
||||
log.Printf("random track loading error for %s: \"%s\"", e.Path, err)
|
||||
continue
|
||||
}
|
||||
failed = false
|
||||
a.setNowRandom(e)
|
||||
a.queue.QueueEmpty <- e
|
||||
break
|
||||
} else {
|
||||
log.Printf("random track error: \"%s\"", err)
|
||||
}
|
||||
a.setNowRandom(e)
|
||||
a.queue.QueueEmpty <- e
|
||||
} else {
|
||||
log.Printf("random track error: \"%s\"", err)
|
||||
|
||||
if e, err = a.getFallbackTrack(); e != nil {
|
||||
}
|
||||
if failed {
|
||||
if e, err := a.getFallbackTrack(); e != nil {
|
||||
//preload
|
||||
if err = e.Load(); err != nil {
|
||||
log.Printf("fallback track loading error for %s: \"%s\"", e.Path, err)
|
||||
|
|
2
queue.go
2
queue.go
|
@ -91,7 +91,6 @@ func (e *QueueTrackEntry) Load() error {
|
|||
return err
|
||||
}
|
||||
|
||||
//close at end, TODO check if it runs
|
||||
runtime.SetFinalizer(s, (*RangeReadSeekCloser).Close)
|
||||
|
||||
e.reader = s
|
||||
|
@ -100,7 +99,6 @@ func (e *QueueTrackEntry) Load() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//close at end, TODO check if it runs
|
||||
runtime.SetFinalizer(f, (*os.File).Close)
|
||||
|
||||
e.reader = f
|
||||
|
|
Loading…
Reference in a new issue