diff --git a/ipinfo/cmd_download.go b/ipinfo/cmd_download.go index 5b37711d..fa1ffc21 100644 --- a/ipinfo/cmd_download.go +++ b/ipinfo/cmd_download.go @@ -146,6 +146,9 @@ func cmdDownload() error { url := fmt.Sprintf("%s%s.%s?token=%s", dbDownloadURL, dbName, format, token) err := downloadDb(url, fileName, format, fZip) + if err != nil { + return err + } // fetch checksums from API and check if they match. checksumUrl := fmt.Sprintf("%s%s.%s/checksums?token=%s", dbDownloadURL, dbName, format, token) @@ -165,10 +168,6 @@ func cmdDownload() error { return errors.New("checksums do not match. File might be corrupted") } - if err != nil { - return err - } - return nil } @@ -288,8 +287,8 @@ func fetchChecksums(url string) (*ChecksumResponse, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { return nil, err