Reduce risk of an interrupted installation leading to a partial installation #2261
+31
−16
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.
Since the installer script uses
mktemp -dto create a directory to store the downloaded release and extract it, the files might end up on a different filesystem than the target installation directory. This means that themvbasically turns into acpfollowed by anrmwhich means that if it gets interrupted at this point, the result could be a partially written file, or just in general an installation with only some of the files written.There's no real way to solve this without support from the filesystem, so instead this PR aims to reduce the window in these cases by first using
mvto copy/move the files into a subdirectory of the target and thenmvthe files out. The second round ofmvshould just berenameunder the hood so this should happen quickly. As an additional side effect, while you might end up with a partial upgrade, you will never end up with a partially written binary.Also, since the temporary directory creation was successful, this means that the final round of
mvis likely to also be successful as both require the same permissions to the parent directory.