mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-07-28 01:27:58 +00:00
fix: explicitly ignore Close() errors in error paths and retry loops
This commit is contained in:
@@ -26,7 +26,7 @@ func DoRequestWithRetry(client *http.Client, req *http.Request) (*http.Response,
|
||||
|
||||
for i := range maxRetries {
|
||||
if i > 0 && resp != nil {
|
||||
resp.Body.Close()
|
||||
_ = resp.Body.Close()
|
||||
}
|
||||
|
||||
resp, err = client.Do(req)
|
||||
@@ -42,7 +42,7 @@ func DoRequestWithRetry(client *http.Client, req *http.Request) (*http.Response,
|
||||
if i < maxRetries-1 {
|
||||
if err = sleepWithCtx(req.Context(), retryDelayForAttempt(resp, i)); err != nil {
|
||||
if resp != nil {
|
||||
resp.Body.Close()
|
||||
_ = resp.Body.Close()
|
||||
}
|
||||
return nil, fmt.Errorf("failed to sleep: %w", err)
|
||||
}
|
||||
|
||||
+1
-1
@@ -176,7 +176,7 @@ func DownloadFile(urlStr, filename string, opts DownloadOptions) string {
|
||||
}
|
||||
|
||||
if _, err := io.Copy(out, resp.Body); err != nil {
|
||||
out.Close()
|
||||
_ = out.Close()
|
||||
os.Remove(localPath)
|
||||
logger.ErrorCF(opts.LoggerPrefix, "Failed to write file", map[string]any{
|
||||
"error": err.Error(),
|
||||
|
||||
Reference in New Issue
Block a user