Skip to main content

Module fs

Module fs 

Source
Expand description

Filesystem helpers shared by the ecosystem crawlers.

Each crawler walks one or more package directories and decides whether each entry is a candidate package. The two operations that all eight crawlers repeat are:

  • listing entries in a directory while tolerating permission / I/O errors (we treat an unreadable directory as “no entries”);
  • asking whether an entry is a directory while tolerating file_type() failures (we treat a stat error as “not a dir”).

Centralizing both keeps each crawler free of the match read_dir { Ok(rd) => rd, Err(_) => return … } boilerplate and gives integration tests a single function to drive when they want to exercise the read_dir Err arm via chmod 000.

Both helpers are async because the rest of the crawler code is — they delegate to tokio::fs.

entry_is_dir follows symlinks (uses metadata(), not symlink_metadata()), matching the historical behavior of the crawlers (pnpm’s content-addressed store relies on resolving symlinks into node_modules/.pnpm/*).

Functions§

entry_file_type
Return the raw FileType for entry, swallowing stat errors.
entry_is_dir
Resolve whether entry is a directory, following symlinks.
list_dir_entries
List the immediate children of path.