ndmitchell / extra

Extra Haskell functions
Other
94 stars 37 forks source link

listFilesRecursive loops on symlink loops #27

Open knupfer opened 7 years ago

ndmitchell commented 7 years ago

Yep, that is almost inevitable. Any recommended suggestions? Documentation seems like a minimal first step.

ndmitchell commented 7 years ago

I added a note to the docs.

knupfer commented 7 years ago

I'd suggest that it doesn't follow symlinks. It seems weird to me that it could return the filepaths parent (if it would return).

ndmitchell commented 7 years ago

That seems a plausible option, using https://hackage.haskell.org/package/directory-1.3.0.1/docs/src/System-Directory.html#pathIsSymbolicLink. Would you list files that are symbolic links? Or just not follow directories that were?

knupfer commented 7 years ago

I'd just not follow directories. This will avoid the most severe class of bugs.

I can imagine that at least someone already did the following:

listFilesRecursively >>= mapM_ removeFile
ndmitchell commented 7 years ago

If you have symlinks to the root or similar, then you probably get away with it because listFilesRecursively will loop forever...

The behaviour of not following inside directories which are symlinks seems reasonable to me.