From 38272a546d12437eb89ed9abd71a8a85e2122006 Mon Sep 17 00:00:00 2001 From: Omar Abdulla Date: Mon, 25 Aug 2025 16:08:03 +0300 Subject: [PATCH] Fix the issue with corpus directory canonicalization --- crates/format/src/corpus.rs | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/crates/format/src/corpus.rs b/crates/format/src/corpus.rs index 13d9280..62e81f6 100644 --- a/crates/format/src/corpus.rs +++ b/crates/format/src/corpus.rs @@ -29,28 +29,16 @@ impl Corpus { ) })?; + let corpus_directory = file_path + .as_ref() + .canonicalize() + .context("Failed to canonicalize the path to the corpus file")? + .parent() + .context("Corpus file has no parent")? + .to_path_buf(); + for path in corpus.paths_iter_mut() { - *path = file_path - .as_ref() - .parent() - .ok_or_else(|| { - anyhow::anyhow!("Corpus path '{}' does not point to a file", path.display()) - }) - .with_context(|| { - format!( - "Failed resolving parent directory for corpus path '{}'", - file_path.as_ref().display() - ) - })? - .canonicalize() - .with_context(|| { - format!( - "Failed to canonicalize path to corpus '{}': {}", - path.display(), - file_path.as_ref().display() - ) - })? - .join(path.as_path()) + *path = corpus_directory.join(path.as_path()) } Ok(corpus)