Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure files are closed before they are deleted or moved in deletetsm #22458

Merged
merged 3 commits into from
Sep 13, 2021

Conversation

danxmoran
Copy link
Contributor

Windows is apparently really strict about enforcing that there are no open handles to a file when you try to move or delete it; if there's a dangling reference, you get a permissions error. It also prevents a move that overwrites an existing file; you have to delete the file at the destination first, then move.


// Replace original file with new file.
if err := os.Rename(outputPath, path); err != nil {
if err := file.RenameFile(outputPath, path); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing helper to first delete path if it's there, then move outputPath -> path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants