From 2b8ee0f2e625f0a5dfc007413febe3cb4cd7cc71 Mon Sep 17 00:00:00 2001 From: aawsome <37850842+aawsome@users.noreply.github.com> Date: Wed, 2 Oct 2024 20:31:18 +0200 Subject: [PATCH] feat(check): Allow to only check trees+packs for given snapshots (#1230) see #251 Co-authored-by: simonsan <14062932+simonsan@users.noreply.github.com> --- src/commands/check.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/commands/check.rs b/src/commands/check.rs index 9393630..7a5e1d8 100644 --- a/src/commands/check.rs +++ b/src/commands/check.rs @@ -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, + /// Check options #[clap(flatten)] opts: CheckOptions, @@ -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(()) } }