use video hard failures

This commit is contained in:
Niko Storni 2020-11-03 22:03:38 +01:00
parent fecf67118c
commit 5b5f7e1c68

View file

@ -722,10 +722,16 @@ func (s *Sync) doSync() error {
} }
close(s.queue) close(s.queue)
s.grp.Wait() s.grp.Wait()
return err if err != nil {
return err
}
if s.hardVideoFailure.failed {
return errors.Err(s.hardVideoFailure.failureReason)
}
return nil
} }
func (s *Sync) startWorker(workerNum int) error { func (s *Sync) startWorker(workerNum int) {
var v ytapi.Video var v ytapi.Video
var more bool var more bool
fatalErrors := []string{ fatalErrors := []string{
@ -781,18 +787,18 @@ func (s *Sync) startWorker(workerNum int) error {
select { select {
case <-s.grp.Ch(): case <-s.grp.Ch():
log.Printf("Stopping worker %d", workerNum) log.Printf("Stopping worker %d", workerNum)
return nil return
default: default:
} }
select { select {
case v, more = <-s.queue: case v, more = <-s.queue:
if !more { if !more {
return nil return
} }
case <-s.grp.Ch(): case <-s.grp.Ch():
log.Printf("Stopping worker %d", workerNum) log.Printf("Stopping worker %d", workerNum)
return nil return
} }
log.Println("================================================================================") log.Println("================================================================================")
@ -802,7 +808,7 @@ func (s *Sync) startWorker(workerNum int) error {
select { // check again inside the loop so this dies faster select { // check again inside the loop so this dies faster
case <-s.grp.Ch(): case <-s.grp.Ch():
log.Printf("Stopping worker %d", workerNum) log.Printf("Stopping worker %d", workerNum)
return nil return
default: default:
} }
tryCount++ tryCount++
@ -813,6 +819,7 @@ func (s *Sync) startWorker(workerNum int) error {
if strings.Contains(strings.ToLower(err.Error()), "interrupted by user") { if strings.Contains(strings.ToLower(err.Error()), "interrupted by user") {
s.grp.Stop() s.grp.Stop()
} else if util.SubstringInSlice(err.Error(), fatalErrors) { } else if util.SubstringInSlice(err.Error(), fatalErrors) {
s.hardVideoFailure.flagFailure(err.Error())
s.grp.Stop() s.grp.Stop()
} else if shouldRetry { } else if shouldRetry {
if util.SubstringInSlice(err.Error(), blockchainErrors) { if util.SubstringInSlice(err.Error(), blockchainErrors) {