From 5b5f7e1c689a021b226c5f9fbf43164a8db38fb6 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Tue, 3 Nov 2020 22:03:38 +0100 Subject: [PATCH] use video hard failures --- manager/ytsync.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/manager/ytsync.go b/manager/ytsync.go index 2e0ae6a..6c3f0c9 100644 --- a/manager/ytsync.go +++ b/manager/ytsync.go @@ -722,10 +722,16 @@ func (s *Sync) doSync() error { } close(s.queue) 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 more bool fatalErrors := []string{ @@ -781,18 +787,18 @@ func (s *Sync) startWorker(workerNum int) error { select { case <-s.grp.Ch(): log.Printf("Stopping worker %d", workerNum) - return nil + return default: } select { case v, more = <-s.queue: if !more { - return nil + return } case <-s.grp.Ch(): log.Printf("Stopping worker %d", workerNum) - return nil + return } log.Println("================================================================================") @@ -802,7 +808,7 @@ func (s *Sync) startWorker(workerNum int) error { select { // check again inside the loop so this dies faster case <-s.grp.Ch(): log.Printf("Stopping worker %d", workerNum) - return nil + return default: } tryCount++ @@ -813,6 +819,7 @@ func (s *Sync) startWorker(workerNum int) error { if strings.Contains(strings.ToLower(err.Error()), "interrupted by user") { s.grp.Stop() } else if util.SubstringInSlice(err.Error(), fatalErrors) { + s.hardVideoFailure.flagFailure(err.Error()) s.grp.Stop() } else if shouldRetry { if util.SubstringInSlice(err.Error(), blockchainErrors) {