Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix is_directory check used in Bos.OS.Path.fold #89

Closed
wants to merge 1 commit into from
Closed

Fix is_directory check used in Bos.OS.Path.fold #89

wants to merge 1 commit into from

Conversation

melwyn95
Copy link

esy uses Bos.OS.Path.fold as a helper to copy files

Recently we face an issue mjambon/dune-deps#23
where esy goes into infinite loops while copying files, the reason for this is,

The project contained a symlink which points to its parent directory (https://github.com/mjambon/dune-deps/blob/master/test/proj/foo/link-to-parent)

The root cause for this infinite loop was Sys.is_directory returned true for the symlink which caused fold to traverse the parent directory repeatedly

The fix for this is to use Unix.lstat to identify the kind of file

@dbuenzli
Copy link
Owner

dbuenzli commented Sep 30, 2021

The fix for this is to use Unix.lstat to identify the kind of file

That's doesn't look like a fix to me. Do you realize it completely breaks the semantics of the function as it exists ?

The standard behaviour of these functions is not to make any distinction between symlinks and what they point to (ideally a follow_symlink argument should be added like here). With that in mind:

  1. It's likely better you do not try to create loops in your file system. You are off for other suprises.
  2. I suspect you can get the behaviour you want by using the traverse callback appropriately.

@melwyn95
Copy link
Author

Thanks @dbuenzli, I completely missed that this case can be handled via the traverse callback, sorry for the bother

@melwyn95 melwyn95 closed this Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants