edcb46a6811d — russes02 10 years ago
Increase timeout incrementally on each failure
1 files changed, 2 insertions(+), 2 deletions(-)

M fetchpage.go
M fetchpage.go +2 -2
@@ 23,7 23,7 @@ func Fetch(phan1, phan2 string, timeout 
 	resultB := make(chan *Result, 2)
 	phanTimeout := "300"
 	if page.Attempts() > 1 {
-		phanTimeout = "5000"
+		phanTimeout = fmt.Sprintf("%d", (page.Attempts()+1) * 5000)
 	}
 	if page.OriginImage() == "" {
 		go fetchPage(phan1, phanTimeout, page.OriginURL(), resultA)

          
@@ 31,7 31,7 @@ func Fetch(phan1, phan2 string, timeout 
 	if page.CopyImage() == "" {
 		go fetchPage(phan2, phanTimeout, page.CopyURL(), resultB)
 	}
-	timer := time.AfterFunc(time.Duration(timeout)*time.Second, func() {
+	timer := time.AfterFunc(time.Duration(timeout * int64(page.Attempts()+1))*time.Second, func() {
 		resultA <- nil
 		resultB <- nil
 	})