mirror of
https://github.com/Cyclenerd/offline-map-tile-downloader.git
synced 2026-06-02 04:45:14 +02:00
Fix: Error return value of resp.Body.Close is not checked
This commit is contained in:
@@ -435,14 +435,18 @@ func downloadTile(ctx context.Context, msgChan chan<- WSMessage, tile Tile, mapS
|
|||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
resp.Body.Close()
|
if err := resp.Body.Close(); err != nil {
|
||||||
|
log.Printf("Could not close response body: %v", err)
|
||||||
|
}
|
||||||
log.Printf("Unexpected status code %d for tile %v. Retrying...", resp.StatusCode, tile)
|
log.Printf("Unexpected status code %d for tile %v. Retrying...", resp.StatusCode, tile)
|
||||||
time.Sleep(time.Second * time.Duration(math.Pow(2, float64(attempt))))
|
time.Sleep(time.Second * time.Duration(math.Pow(2, float64(attempt))))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
resp.Body.Close()
|
if err := resp.Body.Close(); err != nil {
|
||||||
|
log.Printf("Could not close response body: %v", err)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error reading tile body for tile %v: %v. Retrying...", tile, err)
|
log.Printf("Error reading tile body for tile %v: %v. Retrying...", tile, err)
|
||||||
time.Sleep(time.Second * time.Duration(math.Pow(2, float64(attempt))))
|
time.Sleep(time.Second * time.Duration(math.Pow(2, float64(attempt))))
|
||||||
|
|||||||
Reference in New Issue
Block a user