#794 Node, npm and yarn installer delete corrupted archive#807
#794 Node, npm and yarn installer delete corrupted archive#807eirslett merged 1 commit intoeirslett:masterfrom
Conversation
| this.logger.error("The archive file {} is corrupted and will be deleted. " | ||
| + "Please try the build again.", archive.getPath()); | ||
| archive.delete(); | ||
| if (packageDirectory.exists()) { |
There was a problem hiding this comment.
the "package" directory is partially filled (dirty), for this reason should be purged
| this.logger.error("The archive file {} is corrupted and will be deleted. " | ||
| + "Please try the build again.", archive.getPath()); | ||
| archive.delete(); | ||
| FileUtils.deleteDirectory(tmpDirectory); |
There was a problem hiding this comment.
no need to check that tmpDirecory exists (guaranteed by the flow)
| this.logger.error("The archive file {} is corrupted and will be deleted. " | ||
| + "Please try the build again.", archive.getPath()); | ||
| archive.delete(); | ||
| if (installDirectory.exists()) { |
There was a problem hiding this comment.
The above code cleanups the installDirectory, but there is a probabilty to use corrupted (incomplete) Yarn dist.
The node, npm and yarn installer deletes corrupted archive and destination directory in case if the downloading was interrupted (causes EOFException when extracted).
| } | ||
| } | ||
|
|
||
| throw e; |
There was a problem hiding this comment.
the possible alternate option here is to re-download one more time
but the probability of this failure is minor, so in case if it happens the user should not even understand what happened :D
There was a problem hiding this comment.
Related issue - #882 - auto-delete triggers but the auto-retry probably would be nice as a future enhancement
There was a problem hiding this comment.
Actually, downloader would benefit from downloading to a tmp location and then moving post download, I put a comment here.
|
Thanks, that looks good! |
Summary
Issue #794
The node, npm and yarn installer deletes corrupted archive and destination directory in case if the downloading was interrupted (causes EOFException when extracted).
Detailed
The possible real-life example:
This requires manual investigation and deleting the cached archive and can take much time.
How to simulate it locally.
$HOME/.m2/repository/com/github/eirslett/node/${node.version}directory-fullsuffix and make it's partial copy of first bytes:Please note, that no integration tests are provided for the reasons of non-clear approach for it (the build should be interrupted while the archive is being downloaded; or it can be pre-cached manually to the maven directory). I tested it locally step-by-step.
Also please note, that there is another way to solve this:
The downloading should be done to a temp file unless completed and then renamed to destination. Both approaches can be mixed in case if someone will face the described above scenario expecting that it will be solved with plugin update.