Skip to content

Commit

Permalink
feat(check): Allow to only check trees+packs for given snapshots (#1230)
Browse files Browse the repository at this point in the history
see #251

Co-authored-by: simonsan <[email protected]>
  • Loading branch information
aawsome and simonsan authored Oct 2, 2024
1 parent 238ae99 commit 2b8ee0f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ use crate::{commands::open_repository, status_err, Application, RUSTIC_APP};

use abscissa_core::{Command, Runnable, Shutdown};
use anyhow::Result;
use rustic_core::CheckOptions;
use rustic_core::{CheckOptions, SnapshotGroupCriterion};

/// `check` subcommand
#[derive(clap::Parser, Command, Debug)]
pub(crate) struct CheckCmd {
/// Snapshots to check. If none is given, use filter options to filter from all snapshots
#[clap(value_name = "ID")]
ids: Vec<String>,

/// Check options
#[clap(flatten)]
opts: CheckOptions,
Expand All @@ -27,7 +31,16 @@ impl CheckCmd {
fn inner_run(&self) -> Result<()> {
let config = RUSTIC_APP.config();
let repo = open_repository(&config.repository)?;
repo.check(self.opts)?;

let groups = repo.get_snapshot_group(&self.ids, SnapshotGroupCriterion::new(), |sn| {
config.snapshot_filter.matches(sn)
})?;
let trees = groups
.into_iter()
.flat_map(|(_, snaps)| snaps)
.map(|snap| snap.tree)
.collect();
repo.check_with_trees(self.opts, trees)?;
Ok(())
}
}

0 comments on commit 2b8ee0f

Please sign in to comment.