Repository navigation
Keep Go modules that differ only in case apart in the cache - #505
pinguinfuss wants to merge 2 commits into
Conversation
…o github.com/Sirupsen/logrus and github.com/sirupsen/logrus no longer share one cache entry. Lowercase paths keep their filename.
…elling of the module.
andrew
left a comment
There was a problem hiding this comment.
Please bound the case-sensitive cache filename and cover long module paths with the file storage backend.
| if module == strings.ToLower(module) { | ||
| return fmt.Sprintf("%s@%s.zip", lastComponent(module), version) | ||
| } | ||
| return fmt.Sprintf("%s@%s.zip", strings.ReplaceAll(encodeGoModule(module), "/", "_"), version) |
There was a problem hiding this comment.
Flattening the entire module path into one filename can exceed the filesystem's component-length limit, even when every component of the original path is short. I reproduced this through GoHandler.Routes with real file storage and a path accepted by module.CheckPath: example.com/Org/ + 24 repetitions of subpackage/ + leaf (284 characters). GET of its v1.0.0 zip returns 502; storage reports file name too long when creating the temporary file. The same test on main returns 200 with the expected bytes. Use a bounded case-sensitive filename, for example a digest of the module identity, allowing room for the storage temporary-file suffix, and add a handler regression test using file storage.
Fixes #466.
The PURL lowercases Go module paths, so
github.com/Sirupsen/logrusandgithub.com/sirupsen/logrusshared one cache entry and whichever came first was served for both. The go command then failed with a checksum mismatch.github.com_!sirupsen_logrus@v1.0.6.zip. Lowercase paths keeplogrus@v1.0.6.zip, so existing entries stay valid. The PURL stays lowercased, so retention, cooldown and denylist rules match as before.Tested by hand against proxy.golang.org with
go mod download: both logrus spellings come back with the right checksums, and a cache filled by main is repaired on the first request.Left open: during a rolling upgrade where old and new instances share one database, an old instance can write a mixed-up entry again. A new instance repairs it on the next request.