consistency_check in crates/core/dump/src/check.rs deletes orphaned files as a side effect (see TODO in that file). A "check" function shouldn't mutate anything—it should just report what's wrong.
The deletion logic should live in the garbage collector instead. The check function can return the list of orphaned files and let the caller decide what to do with them.