rubygems-mirror
rubygems-mirror copied to clipboard
`gem mirror` should also download the `/versions` file and the `/info/` directory
According to issues like:
- https://github.com/ustclug/discussions/issues/438 (Chinese)
- https://github.com/tuna/issues/issues/374
A full RubyGems mirror generated by gem mirror is not easy to consume - Both gem install and bundle fetches tons of gemspec.rz files if a faster index is not found (previously /api/v1/dependencies, now superseded by /versions + /info/), making a local mirror actually much slower even under terrible availability of rubygems.org (e.g. from mainland China).
If gem mirror could also fetch the versions file and populate the /info/ directory, downstream mirror sites will be much easier to use.
That would be a great improvement, I'd be happy to review a PR if you're able to pull one together!
I took a look at the existing code and it seems too entangled for me to handle. I hope someone from Ruby could take on this.
My ideas are:
- Fetch
/versionsunconditionally and either:- Generate
/versions.md5sumfile so we (mirror sites) can serve its content as the ETag value for the/versionsfile, to maintain compatibility with Bundler 2.4. - Save the
ETagserver header to/versions.md5sumwhich may be even more compatible.
- Generate
- For every gem, fetch
/info/#{gem.name}if either:- The target file is missing.
- A new version of the gem is being fetched.
- For every info file, delete it if deletion is enabled and the corresponding gem has gone.
@iBug Share one of our practices, which is to redirect the /info/ directory to the official address, so that no matter what package is downloaded and installed, the original metadata will be accessed.
According to https://github.com/tuna/issues/issues/2048, a mirror created by gem mirror without additional care is unusable with gem.