Skip to content

Propagate per-entry errors from Path.list! #440

Description

@lukewilliamboswell

Context

hosted_dir_list currently discards errors produced while iterating an otherwise successfully opened directory:

let entries = read_dir
    .filter_map(|entry| entry.ok().map(|entry| entry.path()))
    .collect();

See src/lib.rs:1173-1177.

This can return an incomplete list as Ok when an entry disappears during iteration or the filesystem reports an I/O error. Because Path.list! already returns a Try, silently returning partial data is surprising and can lead applications to make incorrect decisions.

Suggested direction

Collect the iterator as a Result<Vec<_>, io::Error> and map the first entry error through the existing directory error conversion. If partial results are considered useful, expose them through a deliberately different API and result type.

Acceptance criteria

  • An error from any ReadDir entry is not silently dropped.
  • Path.list! returns either a complete snapshot-like result or a typed error.
  • Tests exercise the error branch through a controllable abstraction or filesystem race harness.
  • Existing success and non-directory cases continue to pass on Unix and Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions