Skip to main content

classify_directory

Function classify_directory 

Source
pub fn classify_directory(path: &Path) -> EntryKind
Expand description

Classify a directory without walking it.

Reads one listing, bounded by MAX_ENTRIES_PER_DIR rather than by a probe of the first few entries. A probe makes the answer depend on the order the filesystem hands entries back: a directory of eight Parquet files followed by _metadata.json answered multi locally, where a bucket listing the same directory sorts the JSON first and answered dir.

It costs more than the probe did: a plain directory row is enriched with nothing, so its listing is read for this alone, and a directory of five thousand entries is read whole where eight used to settle it — six hundred times the entries, for the worst row, and look_into_batch walks a batch of sixteen of them one at a time.

That includes rows on a network mount: network_check gates listing a directory you have browsed into, not classifying the rows of one. It is one getdents walk, with a stat only for a symlink, since d_type cannot say what is on the far end of one — so a directory of symlinks is the expensive case. home_open_selected makes the call on the thread reading keys; every other caller is on a worker.

Capping it lower again would put the order-dependence back exactly where the directories are biggest.