google/googet

Caches get mixed up if two repo URLs use the same final path component.

adamcarheden opened this issue · 2 comments

Here's the culprit:

cf := filepath.Join(cacheDir, filepath.Base(p)+".rs")

Example:
googet addrepo first http://myserver.com/googet/myrepo
googet addrepo second gs://my-bucket/googet/myrepo

This will result in googet using C:\ProgramData\googet\cache\myrepo.rs as the cache for both repos. googet available will list both repos but list the set of packages from whichever repo was read most recently for both of them.

The client has a unique name for each repository ('first' and 'second' in the example above). It should use that instead of the final path component.

Note that the fix is easy and I'm glad to submit a PR. However, the rollout could be tricky due to the potential of mixed-up caches. Doing something like giving the cache file a new extension (.rs2 or something) seems like the best way to avoid that. Please let me know if I should:

a) Please submit a PR!
b) No PR necessary, we'll fix it.
c) Too risky -- Let's leave it as-is and maybe put a warning in the docs about it.

Eww, that's some old code, before a lot of the other updates, and why is it using filepath?

The main issue I see is that name is technically not necessary, or even unique among repos, and it is not passed in at all.
A much simpler solution is to just us the full url for the cache file, swapping all the / for _ or something. That way it will always be unique. Feel free to send a PR if you want

Also dont worry about rollout, this should not be an issue as with the new googet version all old cache files will not be read and ignored.