Actually permit multiple state caches to co-exist #4934
Merged
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.
Apropos this morning's dev meeting, it turns out that #4642 is as correct as @AltGr's assertion in #4930 (comment) 😀
OpamRepositoryState.Cache.save
clears all the other caches away, whichis correct except when initialising the cache for the first time, which rather defeats the point. This PR ensures that when the cache is written for the first time, it doesn't erase other caches. All the other (external) paths to the repo cache go via the normal
save
method, and will correctly clear any other caches out of the way.The behaviour can be seen with this repro for #4554 between opam 2.1.1 and opam-state 2.1.0:
The three ls calls will show:
state-028890EA.cache
(opam 2.1.1 state cache)state-392B1E43.cache
(opam-state 2.1.0 state cache, the other one is deleted)state-028890EA.cache
(opam 2.1.1 state cache; again the other one is deleted)Switch in opam 2.1 + this PR, you get:
state-18227757.cache
(opam 2.1.2* state cache)state-392B1E43.cache
(opam-state 2.1.0 state cache, the 2.1.2 cache is incorrectly deleted by opam-state 2.1.0)state-18227757.cache
andstate-392B1E43.cache
(opam 2.1.2* regenerates its state cache and now correctly leaves the other one alone)Then pin opam-state to this PR, and you get the complete correct outcome:
state-18227757.cache
(opam 2.1.2* state cache)state-3F983742.cache
andstate-18227757.cache
(opam-state 2.1.2* correctly adds its cache)state-3F983742.cache
andstate-18227757.cache
(no change)