Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PUP-5018) Cannot unlink dangling Windows symlinks
- When a symlink is created to point at a directory, then that target directory is removed, Windows was previously generating `Errno::EACCES: Permission denied @ unlink_internal` because the underlying Ruby File.unlink was being called, which fails on Windows. When the target no longer exists, Ruby's File.unlink only works properly on symlinks pointed at files and not symlinks pointed at directories. Given the lstat only specifies 'link' and does not describe the target, there is no way of knowing whether the former target was a file or directory. Thefore, when the target stat does not exist, first attempt to File.unlink, and if that fails call Dir.rmdir. Ruby's Dir.rmdir only works on links that were targeted at directories, and not links that were targeted at files.
- Loading branch information