fix(updater): 调整 HTTP 响应状态码的校验逻辑顺序

- 修复在 resp 为 nil 时可能引发状态码检查异常的问题
- 将状态码校验移至 defer resp.Body.Close() 之后以确保资源正确释放
This commit is contained in:
unclesam committed 2026-08-22 17:09:58 +08:00
1 parent 7632652b7b
commit b812ff62f8
1 file changed
+5 -1
+5 -1
View File
@@ -102,11 +102,15 @@ func CheckUpdate(force bool) *UpdateInfo {
client := &http.Client{Timeout: httpTimeout}
resp, err := client.Do(req)
if err != nil || resp == nil || resp.StatusCode != http.StatusOK {
if err != nil || resp == nil {
return nil
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil
}
var release struct {
TagName string `json:"tag_name"`
HTMLURL string `json:"html_url"`