refactor(tvix/castore/blobsvc): use B3Digest Display impl

We don't need to use BASE64 here on our own, B3Digest has a Display
impl.

This will also make sure the `b3:` digest is present in field values.

Change-Id: I0ce6ee0f7e7e99fb9b16872953a1b742e99be291
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11192
Reviewed-by: Connor Brewster <cbrewster@hey.com>
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
Florian Klink 2024-03-18 15:17:57 +02:00 committed by flokli
parent 8d177a18a5
commit 499bc2f7ee
2 changed files with 2 additions and 10 deletions

View file

@ -1,4 +1,3 @@
use data_encoding::BASE64;
use futures::TryStreamExt; use futures::TryStreamExt;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use tokio::io::{AsyncRead, AsyncSeekExt}; use tokio::io::{AsyncRead, AsyncSeekExt};
@ -222,10 +221,7 @@ where
.open_read(&chunk_digest.to_owned()) .open_read(&chunk_digest.to_owned())
.await? .await?
.ok_or_else(|| { .ok_or_else(|| {
warn!( warn!(chunk.digest = %chunk_digest, "chunk not found");
chunk.digest = BASE64.encode(chunk_digest.as_slice()),
"chunk not found"
);
std::io::Error::new(std::io::ErrorKind::NotFound, "chunk not found") std::io::Error::new(std::io::ErrorKind::NotFound, "chunk not found")
})?; })?;

View file

@ -1,4 +1,3 @@
use data_encoding::BASE64;
use futures::{StreamExt, TryStreamExt}; use futures::{StreamExt, TryStreamExt};
use tokio_util::io::{ReaderStream, StreamReader}; use tokio_util::io::{ReaderStream, StreamReader};
use tonic::async_trait; use tonic::async_trait;
@ -114,10 +113,7 @@ where
let blob_service = blob_service.clone(); let blob_service = blob_service.clone();
async move { async move {
blob_service.open_read(&d.to_owned()).await?.ok_or_else(|| { blob_service.open_read(&d.to_owned()).await?.ok_or_else(|| {
warn!( warn!(chunk.digest = %digest, "chunk not found");
chunk.digest = BASE64.encode(digest.as_slice()),
"chunk not found"
);
std::io::Error::new(std::io::ErrorKind::NotFound, "chunk not found") std::io::Error::new(std::io::ErrorKind::NotFound, "chunk not found")
}) })
} }