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

fix(geoip-location): Fix error handling in downloadGeoIpDatabase #2783

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

teogeb
Copy link
Contributor

@teogeb teogeb commented Oct 2, 2024

The code inside this if statement was never run:

if (!isDbFileValid(dbFileInDownloadFolder, remoteHash)) {
    try {
        fs.rmSync(downloadFolder, { recursive: true })
    } catch {
        // ignore error when removing the temporary folder
    }
    throw new Error('Downloaded database hash does not match the expected hash')
}

The isDbFileValid method was async but the call doesn't await it. Therefore the if clause was always false.

Fix

Modified to isDbFileValid to be a sync function as there was nothing async in in the implementation.

@teogeb teogeb merged commit 717ad31 into main Oct 3, 2024
24 checks passed
@teogeb teogeb deleted the fix-downloadGeoIpDatabase-error-handling branch October 3, 2024 13:11
teogeb added a commit that referenced this pull request Oct 4, 2024
…2782)

Enabled the rule. This warned about two issues, there are separate PRs
about those:
- #2783
- #2784
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants