From 8fc17bd9c9d96a6bd954b72608f2e023b5b58243 Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 1 Sep 2022 13:36:33 -0400 Subject: [PATCH] Maybe don't create an infinite loop --- nun.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/nun.go b/nun.go index 1df7c4f..a41c3c1 100644 --- a/nun.go +++ b/nun.go @@ -33,21 +33,22 @@ func (n *nunWatch) Main() { case <-n.stop: return case <-ticker.C: - if n.fail > 5 { - log.Fatal("fail count too high; ending loop") - return - } - if n.fail > 3 { - log.Println("over three failures, increasing tick time by 5x") - ticker.Reset(5 * time.Duration(n.timer) * time.Minute) - break - } + newPost, err := getNewestPost("LittleNuns") if err != nil { log.Printf("error getting newest post: %v", err) log.Println("skipping this cycle, incrementing fail count") n.fail++ - break + if n.fail > 5 { + log.Fatal("fail count too high; ending loop") + return + } else if n.fail > 3 { + log.Println("over three failures, increasing tick time by 5x") + ticker.Reset(5 * time.Duration(n.timer) * time.Minute) + break + } else { + break + } } if n.fail != 0 { n.fail = 0