From bbfc0f4f60dd80b13664113d96943b302abfdc70 Mon Sep 17 00:00:00 2001 From: Robin Salen <30937548+Nashtare@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:23:45 -0400 Subject: [PATCH] Fix `clean` leader's command (#586) * Fix clean command * Clippy --- zero_bin/common/src/prover_state/persistence.rs | 10 ++++++++-- zero_bin/leader/src/main.rs | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/zero_bin/common/src/prover_state/persistence.rs b/zero_bin/common/src/prover_state/persistence.rs index fd45238b9..6096b7ab1 100644 --- a/zero_bin/common/src/prover_state/persistence.rs +++ b/zero_bin/common/src/prover_state/persistence.rs @@ -283,8 +283,14 @@ pub fn delete_all() -> anyhow::Result<()> { let file_path = entry.path(); if file_path.is_file() - && (file_path.starts_with("prover_state") - || file_path.starts_with("verifier_state")) + && (entry + .file_name() + .to_string_lossy() + .starts_with("prover_state") + || entry + .file_name() + .to_string_lossy() + .starts_with("verifier_state")) { // Delete all circuit files. fs::remove_file(file_path)?; diff --git a/zero_bin/leader/src/main.rs b/zero_bin/leader/src/main.rs index dc65f0eac..c0311b15c 100644 --- a/zero_bin/leader/src/main.rs +++ b/zero_bin/leader/src/main.rs @@ -55,6 +55,11 @@ async fn main() -> Result<()> { } let args = cli::Cli::parse(); + + if let Command::Clean = args.command { + return zero_bin_common::prover_state::persistence::delete_all(); + } + let runtime = Arc::new(Runtime::from_config(&args.paladin, register()).await?); let prover_config: ProverConfig = args.prover_config.into(); @@ -69,7 +74,6 @@ async fn main() -> Result<()> { } match args.command { - Command::Clean => zero_bin_common::prover_state::persistence::delete_all()?, Command::Stdio { previous_proof } => { let previous_proof = get_previous_proof(previous_proof)?; stdio::stdio_main(runtime, previous_proof, Arc::new(prover_config)).await?; @@ -118,6 +122,7 @@ async fn main() -> Result<()> { ) .await?; } + Command::Clean => unreachable!("Flushing has already been handled."), } Ok(())