Copy package to destination if move failed during resource installation #1938
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.
Please check if the PR fulfills these requirements
See how to contribute
before creating one)
our contributing guidelines
UPGRADING.md
has been updated with a migration guide (for breaking changes)What kind of change does this PR introduce?
This PR improves compatibility with antivirus software.
What is the current behavior?
CLI reports
if an antivirus software is still scanning temp files when CLI trys to move them to destination dir. This is a common error if you are using an antivirus software, and there are lots of discussion.
All previous suggestion is to disable antivirus temporarily. It's not a good solution because:
Some related issues, all suggested to solve manually:
core install
fails with "Access is denied" error #723What is the new behavior?
CLI will try to copy temp files if move failed, no error will be reported even if antivirus is scanning temp files.
To demonstrate new behavior, I've added debug logs in my demo and the output looks like:
Does this PR introduce a breaking change, and is titled accordingly?
No
Other information
Copy takes a little bit more time than move, but it's only called if move failed. And it's definitely faster and safer than searching for error message, disabling antivirus, and rerun installation.
Temp files will not be left permanently, they will be removed by
defer tempDir.RemoveAll()
here.