refactor(tvix/castore): drop {Directory,File,Symlink}Node
Add a `SymlinkTarget` type to represent validated symlink targets. With this, no invalid states are representable, so we can make `Node` be just an enum of all three kind of types, and allow access to these fields directly. Change-Id: I20bdd480c8d5e64a827649f303c97023b7e390f2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12216 Reviewed-by: benjaminedwardwebb <benjaminedwardwebb@gmail.com> Autosubmit: flokli <flokli@flokli.de> Reviewed-by: Connor Brewster <cbrewster@hey.com> Tested-by: BuildkiteCI
This commit is contained in:
parent
49b173786c
commit
8ea7d2b60e
27 changed files with 555 additions and 461 deletions
|
|
@ -21,7 +21,7 @@ use super::{
|
|||
RootToLeavesValidator,
|
||||
};
|
||||
use crate::composition::{CompositionContext, ServiceBuilder};
|
||||
use crate::{proto, B3Digest, Error};
|
||||
use crate::{proto, B3Digest, Error, Node};
|
||||
|
||||
/// Stores directory closures in an object store.
|
||||
/// Notably, this makes use of the option to disallow accessing child directories except when
|
||||
|
|
@ -85,7 +85,11 @@ impl DirectoryService for ObjectStoreDirectoryService {
|
|||
|
||||
#[instrument(skip(self, directory), fields(directory.digest = %directory.digest()))]
|
||||
async fn put(&self, directory: Directory) -> Result<B3Digest, Error> {
|
||||
if directory.directories().next().is_some() {
|
||||
// Ensure the directory doesn't contain other directory children
|
||||
if directory
|
||||
.nodes()
|
||||
.any(|(_, e)| matches!(e, Node::Directory { .. }))
|
||||
{
|
||||
return Err(Error::InvalidRequest(
|
||||
"only put_multiple_start is supported by the ObjectStoreDirectoryService for directories with children".into(),
|
||||
));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue