Skip to content

mintSources.py: Don't rank mirrors that return HTTP errors in the speed test - #286

Open
Amadeus-22 wants to merge 1 commit into
linuxmint:masterfrom
Amadeus-22:fix-speed-test-http-errors
Open

Amadeus-22 wants to merge 1 commit into
linuxmint:masterfrom
Amadeus-22:fix-speed-test-http-errors

Conversation

@Amadeus-22

Copy link
Copy Markdown

The mirror speed test downloads a test file with pycurl but never checks the HTTP status. A mirror that does not carry the release answers with a 404 page, and the download speed of that error page is reported as the mirror's speed. Such a mirror can sort to the top of the list, and apt update then fails after the user selects it.

Setting pycurl.FAILONERROR makes HTTP errors raise, so the mirror gets 0 and is shown as "Unreachable". Mirrors that serve the file are measured as before, and the existing unit test still passes.

Reproduced with a local mirror that has ls-lR.gz but no dists/noble:

Before: GET .../dists/noble/main/binary-amd64/Packages.gz 404 -> speed test result: 805288.0
After:  error 22 (The requested URL returned error: 404) -> speed test result: 0

🤖 Generated with Claude Code

…ed test

The speed test downloads dists/<codename>/.../Packages.gz (or
Contents-amd64.gz) with pycurl but never checks the HTTP status. A
mirror which doesn't carry the current release answers 404, curl
happily "downloads" the error page, and SPEED_DOWNLOAD reports a
positive speed. The mirror is then listed with a speed and can end up
at the top of the list, and apt update fails after the user picks it.

Set FAILONERROR so HTTP errors raise and the mirror is reported as
unreachable, like any other download failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant