From 9b73913a1acc6728825326fbc2a996ff54ff3c54 Mon Sep 17 00:00:00 2001 From: itowlson Date: Tue, 23 Jul 2024 15:18:23 +1200 Subject: [PATCH] Tell user which file we failed to read Signed-off-by: itowlson --- crates/oci/src/client.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/oci/src/client.rs b/crates/oci/src/client.rs index ba7b282b71..c628ed11be 100644 --- a/crates/oci/src/client.rs +++ b/crates/oci/src/client.rs @@ -513,7 +513,9 @@ impl Client { async fn wasm_layer(file: &Path) -> Result { tracing::trace!("Reading wasm module from {:?}", file); Ok(ImageLayer::new( - fs::read(file).await.context("cannot read wasm module")?, + fs::read(file) + .await + .with_context(|| format!("cannot read wasm module {}", quoted_path(file)))?, WASM_LAYER_MEDIA_TYPE.to_string(), None, )) @@ -522,7 +524,13 @@ impl Client { /// Create a new data layer based on a file. async fn data_layer(file: &Path, media_type: String) -> Result { tracing::trace!("Reading data file from {:?}", file); - Ok(ImageLayer::new(fs::read(&file).await?, media_type, None)) + Ok(ImageLayer::new( + fs::read(&file) + .await + .with_context(|| format!("cannot read file {}", quoted_path(file)))?, + media_type, + None, + )) } fn content_ref_for_layer(&self, layer: &ImageLayer) -> ContentRef {