fix: Respect delete-protection when running forget with ids (#1149)

closes #1148
This commit is contained in:
aawsome 2024-05-07 10:16:50 +02:00 committed by GitHub
parent 7ff4d2f6ff
commit 7665b84f74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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};
@ -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(),
};