extra icon indicating copy to clipboard operation
extra copied to clipboard

listFilesRecursive loops on symlink loops

Open knupfer opened this issue 8 years ago • 6 comments

knupfer avatar Jan 21 '17 16:01 knupfer

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

ndmitchell avatar Jan 22 '17 14:01 ndmitchell

I added a note to the docs.

ndmitchell avatar Jan 22 '17 14:01 ndmitchell

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).

knupfer avatar Jan 22 '17 14:01 knupfer

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?

ndmitchell avatar Jan 22 '17 15:01 ndmitchell

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

knupfer avatar Jan 22 '17 21:01 knupfer

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.

ndmitchell avatar Jan 22 '17 21:01 ndmitchell