haskell / haskell/directory

Recursively delete directories on Windows without race conditions

Open
#110 11 comments 2 reactions 0 assignees View on GitHub
type: (1) bug
Dominant language
Haskell
Stars
65
Forks
52
PR merge metrics
No merged PRs in 30d

Description

[Niall Douglas' "Racing the File System" at *CppCon*](https://youtu.be/uhRWMGBjlO8?t=621) actually outlines a deletion algorithm that works correctly on Windows. It does not require retries.

The gist of it:

- Deletion is effectively asynchronous on Windows.
- If deleting recursively, you want to rename the item you're deleting out of the directory you're deleting first, then delete it.

This provides an alternative solution to the issue described in #96 and #108.

### Alternative

It seems there's yet another way to do this using Windows 10 V1607's POSIX-compatible API:

SetFileInformationByHandle(FILE_DISPOSITION_INFO_EX { FILE_DISPOSITION_DELETE | FILE_DISPOSITION_POSIX_SEMANTICS })

But this is limited to NTFS.

https://stackoverflow.com/a/50234974

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.