Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At present
$OPAMROOT/repo/state.cache
will be reset if the magic string does not match the version of opam-state / opam. This is tedious when developing and also visible to users as opam-state has a slightly different version from an opam binary.The fix is quite simple: include the magic string in the filename as well, and tolerate having multiple cache files.
state.cache
is only ever written if something changed, and all that happens now is that$OPAMROOT/repo/*.cache
is erased prior to writing the new cache (since other opam-state / opam binaries actually must regenerate the file).As the cache files are all reset at
opam update
, even developers shouldn't see too many of them accumulating.Fixes #4554. It can't directly be backported to 2.0.9, because 2.0.8 and earlier don't delete *.cache on a write. The "algorithm" could be adapted where opam 2.0.9 always erases its own cache of
state.cache
is newer, but I'm not convinced this is worth it. opam 2.1 does not require this kind of change, because even if opam 2.0.9 can read an opam root, it's never going to write to it, so the cache can't be invalidated.