opam
opam copied to clipboard
repository: on set-url fetch failure (sync or file error), revert url change an fetch old one
fix #4780 #4779
Thanks!
It feels a bit weird to have fetch the old one again. Is it not possible to have an atomic operation setting the repository config at the end instead of before fetching it?
There is two things: the repo config and repo content. The repository config is overwritten because of called function (minimal modifications makes it easier to overwrite it with the old one). And repository content, on new repository fetch/loading, the old repo is no more present (overwritten), so to keep a consistent state, better fetch the old one. One solution would be to change the behavior to fetch in a temporary directory, check that there is no failure and then fetch in the internal directory.
From dev meeting this morning: there's a slightly different slant on the same idea, which should work! Rather than atomic update at the end - which we can't do easily at the moment - we could back-up whatever is there beforehand (Git repo hash, tarball, directory) and if the set-url fails, then rename that backup back/reset to the SHA.
Updated accordingly, and added a test to check that it is rollbacked to its ineer state (and not remote one)
I think this should be tested with both OPAMREPOSITORYTARRING=0 (as done currently) and OPAMREPOSITORYTARRING=1, since the code touches this.
done :white_check_mark: