refactor(tvix/store/directorysvc): use [u8; 32] instead of Vec<u8>
Also, simplify the trait interface, only allowing lookups of Directory objects by their digest. Change-Id: I6eec28a8cb0557bed9b69df8b8ff99a5e0f8fe35 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8313 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
9c08cbc973
commit
ee23220564
12 changed files with 126 additions and 128 deletions
|
|
@ -103,20 +103,23 @@ impl<BS: BlobService, CS: ChunkService + Clone, DS: DirectoryService> NARRendere
|
|||
}
|
||||
proto::node::Node::Directory(proto_directory_node) => {
|
||||
// get the digest we're referring to
|
||||
let digest = proto_directory_node.digest;
|
||||
let digest: [u8; 32] = proto_directory_node.digest.try_into().map_err(|_e| {
|
||||
RenderError::StoreError(crate::Error::StorageError(
|
||||
"invalid digest len in directory node".to_string(),
|
||||
))
|
||||
})?;
|
||||
|
||||
// look it up with the directory service
|
||||
let resp = self
|
||||
.directory_service
|
||||
.get(&proto::get_directory_request::ByWhat::Digest(
|
||||
digest.to_vec(),
|
||||
))
|
||||
.get(&digest)
|
||||
.map_err(RenderError::StoreError)?;
|
||||
|
||||
match resp {
|
||||
// if it's None, that's an error!
|
||||
None => {
|
||||
return Err(RenderError::DirectoryNotFound(
|
||||
digest,
|
||||
digest.to_vec(),
|
||||
proto_directory_node.name,
|
||||
))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue