From 5618800895d221cfb998e7a7ac7ec098585d581b Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 13 Mar 2025 16:48:32 +0100 Subject: [PATCH] refactor(tvix/castore/directory/object_store): borrow in putter We can share the base_path with the DirectoryService. We cannot share self.object_store, as object_store::buffered::BufWriter wants an Arc. Change-Id: Icfe9d256774de48bb3b4d8afd32620a8188ecfdb Reviewed-on: https://cl.tvl.fyi/c/depot/+/13260 Autosubmit: flokli Tested-by: BuildkiteCI Reviewed-by: edef --- .../castore/src/directoryservice/object_store.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tvix/castore/src/directoryservice/object_store.rs b/tvix/castore/src/directoryservice/object_store.rs index 147a79cbf..ee253b588 100644 --- a/tvix/castore/src/directoryservice/object_store.rs +++ b/tvix/castore/src/directoryservice/object_store.rs @@ -180,13 +180,13 @@ impl DirectoryService for ObjectStoreDirectoryService { } #[instrument(skip_all)] - fn put_multiple_start(&self) -> Box<(dyn DirectoryPutter + 'static)> + fn put_multiple_start(&self) -> Box<(dyn DirectoryPutter + '_)> where Self: Clone, { Box::new(ObjectStoreDirectoryPutter::new( self.object_store.clone(), - self.base_path.clone(), + &self.base_path, )) } } @@ -259,15 +259,15 @@ impl ServiceBuilder for ObjectStoreDirectoryServiceConfig { } } -struct ObjectStoreDirectoryPutter { +struct ObjectStoreDirectoryPutter<'a> { object_store: Arc, - base_path: Path, + base_path: &'a Path, directory_validator: Option>, } -impl ObjectStoreDirectoryPutter { - fn new(object_store: Arc, base_path: Path) -> Self { +impl<'a> ObjectStoreDirectoryPutter<'a> { + fn new(object_store: Arc, base_path: &'a Path) -> Self { Self { object_store, base_path, @@ -277,7 +277,7 @@ impl ObjectStoreDirectoryPutter { } #[async_trait] -impl DirectoryPutter for ObjectStoreDirectoryPutter { +impl DirectoryPutter for ObjectStoreDirectoryPutter<'_> { #[instrument(level = "trace", skip_all, fields(directory.digest=%directory.digest()), err)] async fn put(&mut self, directory: Directory) -> Result<(), Error> { match self.directory_validator { @@ -314,7 +314,7 @@ impl DirectoryPutter for ObjectStoreDirectoryPutter { .ok_or_else(|| Error::InvalidRequest("got no directories".to_string()))? .digest(); - let dir_path = derive_dirs_path(&self.base_path, &root_digest); + let dir_path = derive_dirs_path(self.base_path, &root_digest); match self.object_store.head(&dir_path).await { // directory tree already exists, nothing to do