Skip to content

Commit

Permalink
Add error if minimized corpus exists
Browse files Browse the repository at this point in the history
  • Loading branch information
louismerlin committed Dec 5, 2024
1 parent 4735362 commit 1ad3514
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/bin/cargo-ziggy/minimize.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{find_target, Build, FuzzingEngines, Minimize};
use anyhow::{Context, Result};
use anyhow::{anyhow, Context, Result};
use std::{
env,
fs::{self, File},
Expand All @@ -20,6 +20,10 @@ impl Minimize {
self.target =
find_target(&self.target).context("⚠️ couldn't find target when minimizing")?;

if fs::read_dir(self.output_corpus()).is_ok() {
return Err(anyhow!("Directory {} exists, please move it before running minimization", self.output_corpus()));
}

let entries = fs::read_dir(self.input_corpus())?;
let original_count = entries.filter_map(|entry| entry.ok()).count();
println!("Running minimization on a corpus of {original_count} files");
Expand Down

0 comments on commit 1ad3514

Please sign in to comment.