refactor(tvix/castore): use Directory struct separate from proto one
This uses our own data type to deal with Directories in the castore model. It makes some undesired states unrepresentable, removing the need for conversions and checking in various places: - In the protobuf, blake3 digests could have a wrong length, as proto doesn't know fixed-size fields. We now use `B3Digest`, which makes cloning cheaper, and removes the need to do size-checking everywhere. - In the protobuf, we had three different lists for `files`, `symlinks` and `directories`. This was mostly a protobuf size optimization, but made interacting with them a bit awkward. This has now been replaced with a list of enums, and convenience iterators to get various nodes, and add new ones. Change-Id: I7b92691bb06d77ff3f58a5ccea94a22c16f84f04 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12057 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
		
							parent
							
								
									5d3f3158d6
								
							
						
					
					
						commit
						3ca0b53840
					
				
					 53 changed files with 1429 additions and 1377 deletions
				
			
		|  | @ -1,7 +1,9 @@ | |||
| use std::path::{Path, PathBuf}; | ||||
| 
 | ||||
| use itertools::Itertools; | ||||
| use tvix_castore::proto::{NamedNode, ValidateNodeError}; | ||||
| use tvix_castore::directoryservice::NamedNode; | ||||
| use tvix_castore::directoryservice::Node; | ||||
| use tvix_castore::ValidateNodeError; | ||||
| 
 | ||||
| mod grpc_buildservice_wrapper; | ||||
| 
 | ||||
|  | @ -123,18 +125,17 @@ impl BuildRequest { | |||
|     /// and all restrictions around paths themselves (relative, clean, …) need
 | ||||
|     // to be fulfilled.
 | ||||
|     pub fn validate(&self) -> Result<(), ValidateBuildRequestError> { | ||||
|         // validate all input nodes
 | ||||
|         for (i, n) in self.inputs.iter().enumerate() { | ||||
|             // ensure the input node itself is valid
 | ||||
|             n.validate() | ||||
|                 .map_err(|e| ValidateBuildRequestError::InvalidInputNode(i, e))?; | ||||
|         } | ||||
| 
 | ||||
|         // now we can look at the names, and make sure they're sorted.
 | ||||
|         if !is_sorted( | ||||
|             self.inputs | ||||
|                 .iter() | ||||
|                 .map(|e| e.node.as_ref().unwrap().get_name()), | ||||
|                 // TODO(flokli) handle conversion errors and store result somewhere
 | ||||
|                 .map(|e| { | ||||
|                     Node::try_from(e.node.as_ref().unwrap()) | ||||
|                         .unwrap() | ||||
|                         .get_name() | ||||
|                         .clone() | ||||
|                 }), | ||||
|         ) { | ||||
|             Err(ValidateBuildRequestError::InputNodesNotSorted)? | ||||
|         } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue