Skip to content

Support async getAllPaths() for remote filesystem backends #181

@manishrc

Description

@manishrc

Problem

IFileSystem.getAllPaths() is the only async-incompatible method in the interface (besides the pure resolvePath):

// Every other method returns Promise<...>
getAllPaths(): string[];  // ← sync only

This makes it impossible for remote filesystem implementations (Dropbox, S3, Google Drive, etc.) to support glob expansion (*.txt, /projects/*.md) without an upfront prefetch of the entire file tree.

Commands like find and grep -r work fine — they walk the tree via readdir() which is async. But glob patterns in word expansion call getAllPaths() synchronously, so remote backends must either:

  1. Return [] (globs silently match nothing)
  2. Require users to call a prefetch method before any glob — surprising and easy to forget

Proposal

Make getAllPaths() accept async implementations:

getAllPaths(): string[] | Promise<string[]>;

This is backwards-compatible — existing sync implementations (InMemoryFs, OverlayFs, ReadWriteFs) continue returning string[]. The glob expansion code in the interpreter just needs to await the result (it's already in an async context).

Context

This came up while building just-bash-dropbox, a Dropbox HTTP API backend for IFileSystem. Everything works except globs — find . -name "*.md" works (uses readdir), but cat *.md doesn't (uses getAllPaths).

Tracking issue: manishrc/just-bash-dropbox#1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions