fix: Move existing file out of the way during rename #1794
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.
This pull request illustrates one way of potentially ensuring Windows computers can replace the binary even while it is in use. Unfortunately, I'm not experienced with NeoVim plugin development, and I'm not exactly sure how I would simulate the condition that triggers the bug. I tried setting
lazy.nvim
to get the plugin from a local directory for development, but I'm getting the error about being unable to download the binary without any changes to the code. Since I haven't been able to get themain
branch to work correctly when sourcingblink.cmp
locally, I'm a bit stuck on how to test this.@Saghen, would you mind putting eyes on this anyway? The technique of renaming the existing file (if there is one), then deleting it after
old_path
is renamed tonew_path
should resolve #1493, but it might introduce the possibility that it could fail to delete the file, causing old binaries to accumulate over time. Maybe that should result in a warning, or a lifecycle trigger could attempt to delete stray files silently. That's why I have it renaming files to contain a.trash-
prefix. It makes them easy to identify. My understanding is that recent versions of Windows are POSIX compliant with their unlink implementations, so the files shouldn't accumulate, but there could be an edge case there.