Skip to main content
find, du, ls -R, tree, grep -r and rg can ask your VFS for a whole folder tree in one call, instead of listing each folder. Return None (TypeScript: null) and Mirage lists each folder. For example, S3 answers find /data/ from one recursive listing of the prefix.

read_tree

Every file and folder below one folder.
For a path that is not a folder, raise what readdir raises. These commands call read_tree:
  • find
  • du
  • ls -R
  • tree
  • grep -r, rg
  • cp -r inside the mount, when your VFS overrides copy
These list each folder instead:
  • find -maxdepth N
  • tree -L N
  • rg --max-depth N
  • ls without -R
  • cp -r to another mount

walk_limit

Every walk stops at its command’s walk_limit on your mount, whether read_tree answered or Mirage listed each folder. It is a field of command_limits: the "@all" entry sets it for every command, and an entry named for one command, such as find, changes only how far that command walks. The mount’s "@all" entry, else the workspace’s, also sets your VFS’s own walk_limit, which decides how it searches: with the service’s search under a cap, by reading every file at -1. Return None for a folder too large to send in one call: Mirage then stops calling readdir once the limit is spent. To stop paging early, take limit (TypeScript: handed.limit), how many entries the walk can still use:
limit is None (TypeScript: undefined) when nothing caps the walk. Without it, read_tree returns the whole tree and the command keeps what fits.

Example

This example extends NotesVFS from Custom VFS. Its pages sit in one folder, so one readdir is the whole tree; a service with nested folders would return them all from one recursive call:
find /notes, du -a /notes, ls -R /notes and tree /notes then call read_tree once. find /notes -maxdepth 1 lists the folder instead.