Skip to content

Commit

Permalink
fix: img pool
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed May 4, 2024
1 parent c34b727 commit f4f0039
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions img/pool/img.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,18 @@ func GetImage(name string) (m *Image, err error) {
var resp *http.Response
resp, err = http2.Head(m.String())
if err == nil {
return
}
if resp.StatusCode == http.StatusNotFound {
logrus.Debugln("[imgpool] image", name, m, "outdated:", err)
err = ErrImgFileOutdated
return
if resp.StatusCode == http.StatusOK {
return
}
if resp.StatusCode == http.StatusNotFound {
logrus.Debugln("[imgpool] image", name, m, "outdated:", err)
err = ErrImgFileOutdated
return
}
}
resp, err = http2.Get(m.String())
_ = resp.Body.Close()
if err == nil {
if err == nil && resp.StatusCode == http.StatusOK {
return
}
err = ErrImgFileOutdated
Expand All @@ -75,14 +77,16 @@ func NewImage(send ctxext.NoCtxSendMsg, get ctxext.NoCtxGetMsg, name, f string)
var resp *http.Response
resp, err = http2.Head(m.String())
if err == nil {
return
}
if resp.StatusCode != http.StatusNotFound {
resp, err = http2.Get(m.String())
_ = resp.Body.Close()
if err == nil {
if resp.StatusCode == http.StatusOK {
return
}
if resp.StatusCode != http.StatusNotFound {
resp, err = http2.Get(m.String())
_ = resp.Body.Close()
if err == nil && resp.StatusCode == http.StatusOK {
return
}
}
}
logrus.Debugln("[imgpool] image", name, m, "outdated:", err, "updating...")
}
Expand Down

0 comments on commit f4f0039

Please sign in to comment.