classify_index_walk_error

Function classify_index_walk_error 

Source
pub(super) fn classify_index_walk_error(
    cache_dir: &Path,
    err: Error,
) -> Option<ApiError>
Expand description

Classify an error yielded by cacache::list_sync on a walk that may be starting from a cache that was never written to.

The ONE benign case takes BOTH halves of a conjunction, and each half closes a different way of reading a broken cache as an empty one:

  • the index root must be ABSENT, so the walk demonstrably never started. A NotFound raised part-way through a walk (a bucket or subdirectory disappearing under it) is a real failure; treating it as “the cache is empty” is how a truncated walk gets to unlink live content.
  • the cache directory itself must still be PRESENT. If it is gone too – an unmounted volume, a wiped CACHE_DIR – the same NotFound means the store is unreadable, and answering “0 entries” would make a broken cache indistinguishable from a healthy empty one.

Note what cacache does NOT report: bucket_entries drops unreadable and unparseable index LINES silently (map_while(Result::ok) then a filter_map that yields None for a bad line), and turns a NotFound on opening a bucket into an empty vec. Only a failure to open a bucket for some other reason (a permission error, say) and the directory walk itself can produce the errors classified here.

Some(err) means “propagate this”; None means “the cache is empty, stop walking”.