Skip to content

Cache Go modules that differ only in case apart - #540

Merged
andrew merged 1 commit into
git-pkgs:mainfrom
simonchrz:fix/go-module-case
Oct 21, 2026
Merged

andrew merged 1 commit into
git-pkgs:mainfrom
simonchrz:fix/go-module-case

Conversation

@simonchrz

Copy link
Copy Markdown
Contributor

Fixes #466.

Go module zips are stored under the module's PURL, which lowercases golang names, and under {last element}@{version}.zip. github.com/Sirupsen/logrus and github.com/sirupsen/logrus therefore shared one cache entry although upstream serves different zips, and whichever was requested second failed go's checksum check.

  • A module path with capitals now gets a hash of its exact spelling in the filename, logrus@v1.0.6~{hash}.zip. All-lowercase paths keep the plain name, so existing cache entries stay valid.
  • A capitalised module cached before this change sits under its lowercase twin's plain filename. When a cached zip's upstream URL names a different module path, it is discarded and fetched again. Only the module path is compared, so a cache filled from another upstream.go host is kept (Changing upstream invalidates the cache #486), and a record whose URL isn't a Go module URL is left alone.
  • The PURL itself stays lowercase, so both spellings are still one package for retention rules, the UI and the cache API.

Testing

Handler tests fetch both spellings twice and check each gets its own bytes and is fetched once, that a legacy entry for the other spelling is refetched, and that an entry from another upstream host is served from cache. The golang retention test now finds the capitalised module under its new filename.

Module zips are stored under the module's PURL, which lowercases golang
names, and under the filename {last element}@{version}.zip. So
github.com/Sirupsen/logrus and github.com/sirupsen/logrus shared one
cache entry although upstream serves different zips, and the second one
requested failed go's checksum check.

A module path with capitals now gets a hash of its exact spelling in the
filename. All-lowercase paths keep the plain name, so existing cache
entries stay valid.

A capitalised module cached before this change sits under its lowercase
twin's plain filename. When a cached zip's upstream URL names a different
module path, it is discarded and fetched again. Only the module path is
compared, so a cache filled from another upstream.go host is kept.

Fixes git-pkgs#466
@andrew
andrew merged commit 10fc27b into git-pkgs:main Oct 21, 2026
6 checks passed
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.

Go: modules that differ only in case are served each other’s zip

2 participants