Skip to content

Commit

Permalink
fix: Respect delete-protection when running forget with ids (#1149)
Browse files Browse the repository at this point in the history
closes #1148
  • Loading branch information
aawsome committed May 7, 2024
1 parent 7ff4d2f commit 7665b84
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/commands/forget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use abscissa_core::{config::Override, Shutdown};
use abscissa_core::{Command, FrameworkError, Runnable};
use anyhow::Result;

use chrono::Local;
use merge::Merge;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};
Expand Down Expand Up @@ -108,15 +109,26 @@ impl ForgetCmd {
config.forget.filter.matches(sn)
})?
} else {
let now = Local::now();
let item = ForgetGroup {
group: SnapshotGroup::default(),
snapshots: repo
.get_snapshots(&self.ids)?
.into_iter()
.map(|sn| ForgetSnapshot {
snapshot: sn,
keep: false,
reasons: vec!["id argument".to_string()],
.map(|sn| {
if sn.must_keep(now) {
ForgetSnapshot {
snapshot: sn,
keep: true,
reasons: vec!["snapshot".to_string()],
}
} else {
ForgetSnapshot {
snapshot: sn,
keep: false,
reasons: vec!["id argument".to_string()],
}
}
})
.collect(),
};
Expand Down

0 comments on commit 7665b84

Please sign in to comment.