Skip to content

diskern scan reports a clean, empty result for a path that doesn't exist #82

Description

@Muawiya-contact

A root that does not exist produces the same output as a disk with
nothing on it:

$ diskern scan /nonexistnt-path
Scanned 0 files.
Reclaimable: 0 B across 0 findings and 0 duplicate sets.
$ echo $?
0

So does no path at all — roots is a plain Vec<PathBuf> with no
required, and diskern scan on its own is accepted, scans nothing and
exits 0:

$ diskern scan --json
{
  "findings": [],
  "duplicate_sets": [],
  "total_reclaimable": 0,
  "files_scanned": 0
}

Both are the worst answer a disk tool can give a typo: "there is nothing
here" is a plausible result, so nothing tells the user to look again. The
--json case is the one that hurts downstream — a script cannot tell an
empty report from a mistyped path.

The walk swallows it on purpose one layer down: walk_root skips entries
jwalk returns an error for, which is right for the permission errors it
was written for and wrong for a root that was never there.

Two small changes in the CLI, and they can be one PR:

  • make the argument required (#[arg(required = true)], or num_args = 1..)
    so clap prints the usage error itself;
  • check each root exists before scanning and fail with the path that was
    wrong, rather than reporting an empty scan.

A non-zero exit code for the second case matters as much as the message.

crates/diskern-cli/src/main.rs:22 · crates/diskern-cli/src/main.rs:200

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclidiskern-cli: the terminal frontendgood first issueGood for newcomerslevel: beginnerSmall and well-scoped; no deep context neededpriority: mediumWorth doing, not urgent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions