hyperdrive icon indicating copy to clipboard operation
hyperdrive copied to clipboard

readdir() w/recursive=true needs to handle mount-cycles and large mount-graphs

Open pfrazee opened this issue 5 years ago • 2 comments

Currently if you have a "mount cycle" (2 drives that mount each other) the readdir() call with {recursive: true} will enter an endless loop.

Even without a cycle, mount-graphs have the potential to become so large that recursion is not feasible. (E.g. Beaker's use of mounts for the social graph could cause a recursive readdir to iterate the "strong set.")

Ways we can solve this:

  • Add a depth parameter to limit the number of recursions into subfolders
  • Add a mountDepth parameter to limit the number of recursions into mounts
  • Don't recurse into mounts at all (aka mountDepth is always 0)

Ways we can't solve this:

  • Track mounts and break cycles. This would solve the cycle problem but large mount-graphs would still be an issue.

I personally prefer either the mountDepth option or not recursing into mounts.

pfrazee avatar Dec 17 '19 18:12 pfrazee

Is this related to https://github.com/mafintosh/hyperdrive/issues/258?

jb33k avatar Dec 17 '19 18:12 jb33k

It doesn't look like it, the test case in #257 doesn't use recursive readdir

pfrazee avatar Dec 17 '19 19:12 pfrazee