about summary refs log tree commit diff
path: root/tvix/store/src/nar
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/store/src/nar')
-rw-r--r--tvix/store/src/nar/renderer.rs33
1 files changed, 19 insertions, 14 deletions
diff --git a/tvix/store/src/nar/renderer.rs b/tvix/store/src/nar/renderer.rs
index 9b71d24ac2a9..1804674fc44a 100644
--- a/tvix/store/src/nar/renderer.rs
+++ b/tvix/store/src/nar/renderer.rs
@@ -1,15 +1,13 @@
-use std::io::{self, BufReader};
-
+use super::RenderError;
 use crate::{
     blobservice::BlobService,
     directoryservice::DirectoryService,
     proto::{self, NamedNode},
     B3Digest,
 };
-use data_encoding::BASE64;
 use nix_compat::nar;
-
-use super::RenderError;
+use std::io::{self, BufReader};
+use tracing::warn;
 
 /// A NAR renderer, using a blob_service, chunk_service and directory_service
 /// to render a NAR to a writer.
@@ -58,19 +56,26 @@ impl<BS: BlobService, DS: DirectoryService> NARRenderer<BS, DS> {
                     .map_err(RenderError::NARWriterError)?;
             }
             proto::node::Node::File(proto_file_node) => {
-                let digest: [u8; 32] =
-                    proto_file_node.digest.to_owned().try_into().map_err(|_e| {
-                        RenderError::StoreError(crate::Error::StorageError(
-                            "invalid digest len in file node".to_string(),
-                        ))
-                    })?;
+                let digest = B3Digest::from_vec(proto_file_node.digest.clone()).map_err(|_e| {
+                    warn!(
+                        file_node = ?proto_file_node,
+                        "invalid digest length in file node",
+                    );
+
+                    RenderError::StoreError(crate::Error::StorageError(
+                        "invalid digest len in file node".to_string(),
+                    ))
+                })?;
 
-                // TODO: handle error
-                let mut blob_reader = match self.blob_service.open_read(&digest).unwrap() {
+                let mut blob_reader = match self
+                    .blob_service
+                    .open_read(&digest)
+                    .map_err(|e| RenderError::StoreError(e))?
+                {
                     Some(blob_reader) => Ok(BufReader::new(blob_reader)),
                     None => Err(RenderError::NARWriterError(io::Error::new(
                         io::ErrorKind::NotFound,
-                        format!("blob with digest {} not found", BASE64.encode(&digest)),
+                        format!("blob with digest {} not found", &digest),
                     ))),
                 }?;