diff options
author | Yureka <tvl@yuka.dev> | 2024-07-23T13·32+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-07-23T14·04+0000 |
commit | 94a0e21e68e75c758d1df055890bde8b843fb5ef (patch) | |
tree | 73c2b574798ec6701c65851318cfed8ac32846a8 /tvix/castore/src/directoryservice/utils.rs | |
parent | b9aa6456e22c562fbf849609112194d7ae7c1447 (diff) |
fix(tvix/directoryservice): clarify get_recursive not found r/8407
Change-Id: I47f21b4b7db9304eadb04094d41bf04d443fcc3b Reviewed-on: https://cl.tvl.fyi/c/depot/+/12025 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: yuka <yuka@yuka.dev>
Diffstat (limited to 'tvix/castore/src/directoryservice/utils.rs')
-rw-r--r-- | tvix/castore/src/directoryservice/utils.rs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/tvix/castore/src/directoryservice/utils.rs b/tvix/castore/src/directoryservice/utils.rs index a0ba395ecda8..726734f55eec 100644 --- a/tvix/castore/src/directoryservice/utils.rs +++ b/tvix/castore/src/directoryservice/utils.rs @@ -25,23 +25,31 @@ pub fn traverse_directory<'a, DS: DirectoryService + 'static>( // We omit sending the same directories multiple times. let mut sent_directory_digests: HashSet<B3Digest> = HashSet::new(); + let root_directory_digest = root_directory_digest.clone(); + Box::pin(try_stream! { while let Some(current_directory_digest) = worklist_directory_digests.pop_front() { - let current_directory = directory_service.get(¤t_directory_digest).await.map_err(|e| { + let current_directory = match directory_service.get(¤t_directory_digest).await.map_err(|e| { warn!("failed to look up directory"); Error::StorageError(format!( "unable to look up directory {}: {}", current_directory_digest, e )) - })?.ok_or_else(|| { - // if it's not there, we have an inconsistent store! - warn!("directory {} does not exist", current_directory_digest); - Error::StorageError(format!( - "directory {} does not exist", - current_directory_digest - )) + })? { + // the root node of the requested closure was not found, return an empty list + None if current_directory_digest == root_directory_digest => break, + // if a child directory of the closure is not there, we have an inconsistent store! + None => { + warn!("directory {} does not exist", current_directory_digest); + Err(Error::StorageError(format!( + "directory {} does not exist", + current_directory_digest + )))?; + break; + } + Some(dir) => dir, + }; - })?; // validate, we don't want to send invalid directories. current_directory.validate().map_err(|e| { |