feat(processor): add execute flag for dry run

- introduce execute flag to control actual execution of actions
- add set_execute method to modify the execute flag
- log warning message when execution is stopped for dry run
This commit is contained in:
Jeremiah Russell
2025-10-12 07:05:05 +01:00
committed by Jeremiah Russell
parent 89dd35d487
commit aa1074d4bb

View File

@@ -25,6 +25,11 @@ impl<'a> Processor<'a> {
self.rule.action()
}
/// Set the execute flag
pub fn set_execute(&mut self, value: bool) {
self.execute = value
}
/// Trash the messages
pub async fn trash_messages(&self, label: &str) -> Result<()> {
let mut messages_to_trash = Trash::new(&self.credential_file).await?;
@@ -46,9 +51,10 @@ impl<'a> Processor<'a> {
log::info!("Ready to run");
messages_to_trash.prepare(0).await?;
if self.execute {
log::warn!("***executing final delete messages***");
log::info!("***executing final delete messages***");
messages_to_trash.batch_trash().await
} else {
log::warn!("Execution stopped for dry run");
Ok(())
}
}
@@ -75,9 +81,11 @@ impl<'a> Processor<'a> {
log::info!("Ready to run");
messages_to_delete.prepare(0).await?;
if self.execute {
log::warn!("***executing final delete messages***");
log::info!("***executing final delete messages***");
messages_to_delete.batch_delete().await
} else {
log::warn!("Execution stopped for dry run");
Ok(())
}
}