Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performing checksum comparison on downloaded databases in CLI #160

Merged
merged 3 commits into from
Aug 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Refactoring
Harisabdullah committed Aug 7, 2023
commit b96512a039fb42542c708b186cd924665949d9e6
9 changes: 4 additions & 5 deletions ipinfo/cmd_download.go
Original file line number Diff line number Diff line change
@@ -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