From 46112fbca754d64e108fdb5f105964af470cc1f6 Mon Sep 17 00:00:00 2001 From: Laptop Date: Mon, 7 Oct 2024 19:46:23 +0300 Subject: [PATCH] prevent loops of nothingness --- lib/sc/init.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/sc/init.go b/lib/sc/init.go index 1a8fb93..d0be3fc 100644 --- a/lib/sc/init.go +++ b/lib/sc/init.go @@ -182,6 +182,7 @@ func (p *Paginated[T]) Proceed() error { req := fasthttp.AcquireRequest() defer fasthttp.ReleaseRequest(req) + oldNext := p.Next req.SetRequestURI(p.Next + "&client_id=" + cid) req.Header.Set("User-Agent", cfg.UserAgent) req.Header.Set("Accept-Encoding", "gzip, deflate, br, zstd") @@ -203,7 +204,16 @@ func (p *Paginated[T]) Proceed() error { data = resp.Body() } - return cfg.JSON.Unmarshal(data, p) + err = cfg.JSON.Unmarshal(data, p) + if err != nil { + return err + } + + if p.Next == oldNext { // prevent loops of nothingness + p.Next = "" + } + + return nil } func TagListParser(taglist string) (res []string) {