From 99cc5b6b285fa4f8297ca34ba538912926642393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 5 May 2024 16:45:55 +0900 Subject: [PATCH] chore: update deps --- go.mod | 2 +- img/pool/img.go | 34 ++++++---------------------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/go.mod b/go.mod index 7708dd1..f49d8e6 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,6 @@ require ( github.com/fumiama/cron v1.3.0 github.com/fumiama/go-base16384 v1.7.0 github.com/fumiama/go-registry v0.2.6 - github.com/fumiama/terasu v0.0.0-20240502091919-c887e26289a8 github.com/gin-gonic/gin v1.8.2 github.com/go-playground/assert/v2 v2.2.0 github.com/go-playground/validator/v10 v10.11.1 @@ -39,6 +38,7 @@ require ( github.com/fumiama/go-simple-protobuf v0.1.0 // indirect github.com/fumiama/gofastTEA v0.0.10 // indirect github.com/fumiama/imgsz v0.0.2 // indirect + github.com/fumiama/terasu v0.0.0-20240502091919-c887e26289a8 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonreference v0.19.6 // indirect diff --git a/img/pool/img.go b/img/pool/img.go index 9307b32..c73bd37 100644 --- a/img/pool/img.go +++ b/img/pool/img.go @@ -10,7 +10,6 @@ import ( "regexp" "strings" - "github.com/fumiama/terasu/http2" "github.com/sirupsen/logrus" "github.com/wdvxdr1123/ZeroBot/message" @@ -43,18 +42,6 @@ func GetImage(name string) (m *Image, err error) { m.n = name m.item, err = getItem(name) if err == nil && m.u != "" { - var resp *http.Response - resp, err = http2.Head(m.String()) - if err == nil { - if resp.StatusCode == http.StatusOK { - return - } - if resp.StatusCode == http.StatusNotFound { - logrus.Debugln("[imgpool] image", name, m, "outdated, code:", resp.StatusCode) - err = ErrImgFileOutdated - return - } - } _, err = web.RequestDataWithHeaders(http.DefaultClient, m.String(), "GET", func(r *http.Request) error { r.Header.Set("Range", "bytes=0-1") r.Header.Set("User-Agent", web.RandUA()) @@ -79,22 +66,13 @@ func NewImage(send ctxext.NoCtxSendMsg, get ctxext.NoCtxGetMsg, name, f string) m.SetFile(f) m.item, err = getItem(name) if err == nil && m.item.u != "" { - var resp *http.Response - resp, err = http2.Head(m.String()) + _, err = web.RequestDataWithHeaders(http.DefaultClient, m.String(), "GET", func(r *http.Request) error { + r.Header.Set("Range", "bytes=0-1") + r.Header.Set("User-Agent", web.RandUA()) + return nil + }, nil) if err == nil { - if resp.StatusCode == http.StatusOK { - return - } - if resp.StatusCode != http.StatusNotFound { - _, err = web.RequestDataWithHeaders(http.DefaultClient, m.String(), "GET", func(r *http.Request) error { - r.Header.Set("Range", "bytes=0-1") - r.Header.Set("User-Agent", web.RandUA()) - return nil - }, nil) - if err == nil { - return - } - } + return } logrus.Debugln("[imgpool] image", name, m, "outdated:", err, "updating...") }