From b7df3713001f435127a5c6fe50c56a6edd39e424 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 04:04:35 +0900 Subject: [PATCH] fix: img pool --- img/pool/img.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/img/pool/img.go b/img/pool/img.go index 74d6a02..9c143a6 100644 --- a/img/pool/img.go +++ b/img/pool/img.go @@ -55,9 +55,11 @@ func GetImage(name string) (m *Image, err error) { } } resp, err = http2.Get(m.String()) - _ = resp.Body.Close() - if err == nil && resp.StatusCode == http.StatusOK { - return + if err == nil { + _ = resp.Body.Close() + if resp.StatusCode == http.StatusOK { + return + } } err = ErrImgFileOutdated return @@ -82,9 +84,11 @@ func NewImage(send ctxext.NoCtxSendMsg, get ctxext.NoCtxGetMsg, name, f string) } if resp.StatusCode != http.StatusNotFound { resp, err = http2.Get(m.String()) - _ = resp.Body.Close() - if err == nil && resp.StatusCode == http.StatusOK { - return + if err == nil { + _ = resp.Body.Close() + if resp.StatusCode == http.StatusOK { + return + } } } }