Skip to content

Support deleting symlinks in Lwt_io.with_temp_dir on Windows - #886

Merged
smorimoto merged 1 commit into
ocsigen:masterfrom
MisterDA:with-temp-dir-symlinks
Nov 7, 2021
Merged

smorimoto merged 1 commit into
ocsigen:masterfrom
MisterDA:with-temp-dir-symlinks

Conversation

@MisterDA

@MisterDA MisterDA commented Sep 16, 2021 •

Copy link
Copy Markdown
Contributor

If a Windows symlink points to a directory, then rmdir is the correct
function to call. If it points to a file, then unlink is the correct
function. When pointing to a file, the symlink can also have the
read-only attribute, which makes it subject of the little chmod dance.

This depends on the fix in #883.

@smorimoto

Copy link
Copy Markdown
Member

@MisterDA Could you rebase this?

@MisterDA
MisterDA force-pushed the with-temp-dir-symlinks branch from cd95cc4 to ce82439 Compare October 6, 2021 13:07
@MisterDA

MisterDA commented Oct 6, 2021

Copy link
Copy Markdown
Contributor Author

Rebased.

@smorimoto

Copy link
Copy Markdown
Member

Thanks!

@MisterDA

MisterDA commented Oct 7, 2021

Copy link
Copy Markdown
Contributor Author

This is related to ocaml/ocaml#10642. At the moment neither Sys.remove nor Unix.unlink can remove symlinks to directories on Windows, but POSIX unlink(2) can remove symlinks (regardless of whether they're symlinks to files or directories).
I think I'll probably provide write in the future the variant that the comment suggest, switching to blocking files and a detached thread.

@MisterDA MisterDA mentioned this pull request Oct 21, 2021
1 task
If a Windows symlink points to a directory, then rmdir is the correct
function to call. If it points to a file, then unlink is the correct
function. When pointing to a file, the symlink can also have the
read-only attribute, which makes it subject of the little chmod dance.
@smorimoto
smorimoto force-pushed the with-temp-dir-symlinks branch from ce82439 to e902075 Compare November 7, 2021 06:04
@smorimoto
smorimoto merged commit 99c5635 into ocsigen:master Nov 7, 2021
@MisterDA
MisterDA deleted the with-temp-dir-symlinks branch November 7, 2021 11:05
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.

2 participants