panamax icon indicating copy to clipboard operation
panamax copied to clipboard

Adding feature to fix mirror if any missing crates are found.

Open ricked-twice opened this issue 2 years ago • 0 comments

This PR should definitely fix #64.

This is a huge single commit.

TLDR:

  • Modified Panamax::Verify variant to take two options:
    • --dry_run: whether to fix or just check mirror state;
    • --assume_yes: allowing users to skip verification phase before downloading anything.
  • Modified mirror::verify to take those arguments into account;
  • Modification on verify:
    • Added Input enum to handle user's input through FromStr trait;
    • Added tests to check FromStr implementation;
    • Removed VerifyError enum;
    • Modified verify_mirror to return Result<Option<Vec>, MirrorError>;
    • Added handle_user_input function to let user filter or not missing crates before downloading them;
    • Added fix_mirror function to actually download missing crates.

The verify feature is now able to download any missing crates. By default it is asking user's confirmation before downloading any found missing crates and allow them to filter missing crates to download.

It can take several options:

# only checking if missing crates are found and print them to stdout
$ panamax verify --dry-run /path/to/mirror
# fixing mirror if needed without any user's interaction
$ panamax verify --assume-yes /path/to/mirror

ricked-twice avatar May 31 '22 17:05 ricked-twice