Closed joeyh closed 2 years ago
The haddock does actually warn about this, but in my experience this is easy to miss.
-- Unlike other removal functions, this function will also attempt to delete -- files marked as read-only or otherwise made unremovable due to permissions. -- As a result, if the removal is incomplete, the permissions or attributes on -- the remaining files may be altered. If there are hard links in the -- directory, then permissions on all related hard links may be altered.
I doubt that changing the permissions of a file is ever necessary to let it be deleted.
On Windows, read-only files cannot be removed unless the read-only attribute is removed.
One possible workaround might be to only modify permissions of files on Windows platforms, at the cost of additional complexity.
When a file is a hard link, removePathForcibly will modify the permissions of files outside the directory being deleted:
I doubt that changing the permissions of a file is ever necessary to let it be deleted.
If it only changed the permissions of directories, which can be necessary, it would avoid this problem.