diff options
author | Connor Brewster <cbrewster@hey.com> | 2024-04-18T18·51-0500 |
---|---|---|
committer | Connor Brewster <cbrewster@hey.com> | 2024-04-19T20·37+0000 |
commit | 259d7a3cfa214e7eab7b0862024d595489e92592 (patch) | |
tree | f6f52a334d5e5d26e6f3c323db0f8e56beaf56c8 /tvix/store/src/bin | |
parent | 150106610e60e95267c0968a9679797b05db7f3d (diff) |
refactor(tvix/castore): generalize store ingestion streams r/7979
Previously the store ingestion code was coupled to `walkdir::DirEntry`s produced by the `walkdir` crate which made it impossible to reuse ingesting from other sources like tarballs or NARs. This introduces a `IngestionEntry` which carries enough information for store ingestion and a future for computing the Blake3 digest of files. This allows the producer to perform file uploads in a way that makes sense for the source, ie. the filesystem upload could concurrently upload multiple files at the same time, while the NAR ingestor will need to ingest the entire blob before yielding the next blob in the stream. In the future we can buffer small blobs and upload them concurrently, but the full blob still needs to be read from the NAR before advancing. Change-Id: I6d144063e2ba5b05e765bac1f27d41b3c8e7b283 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11462 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src/bin')
-rw-r--r-- | tvix/store/src/bin/tvix-store.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs index 15f37d301f9d..1f172d65c62f 100644 --- a/tvix/store/src/bin/tvix-store.rs +++ b/tvix/store/src/bin/tvix-store.rs @@ -5,6 +5,7 @@ use futures::future::try_join_all; use nix_compat::path_info::ExportedPathInfo; use serde::Deserialize; use serde::Serialize; +use std::os::unix::ffi::OsStrExt; use std::path::PathBuf; use std::sync::Arc; use tokio_listener::Listener; @@ -430,9 +431,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { } let path: PathBuf = elem.path.to_absolute_path().into(); + let root_name = path.file_name().unwrap().as_bytes().to_vec().into(); // Ingest the given path - let root_node = - ingest_path(blob_service.clone(), directory_service.clone(), path).await?; + let root_node = ingest_path(blob_service.clone(), directory_service.clone(), &path) + .await? + .rename(root_name); // Create and upload a PathInfo pointing to the root_node, // annotated with information we have from the reference graph. |