From 30950833c943c6b6b48d204ab0027f38af356f5c Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 22 Apr 2024 15:18:14 +0300 Subject: feat(tvix/glue/store_io): have KnownPaths track fetches too Have fetcher builtins call queue_fetch() whenever they don't need to fetch something immediately, and teach TvixStoreIO::store_path_to_node on how to look up (and call ingest_and persist on our Fetcher). Change-Id: Id4bd9d639fac9e4bee20c0b1c584148740b15c2f Reviewed-on: https://cl.tvl.fyi/c/depot/+/11501 Reviewed-by: raitobezarius Tested-by: BuildkiteCI Autosubmit: flokli --- tvix/glue/src/builtins/fetchers.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'tvix/glue/src/builtins/fetchers.rs') diff --git a/tvix/glue/src/builtins/fetchers.rs b/tvix/glue/src/builtins/fetchers.rs index ec5dd969bced..0de3d5462561 100644 --- a/tvix/glue/src/builtins/fetchers.rs +++ b/tvix/glue/src/builtins/fetchers.rs @@ -87,11 +87,20 @@ pub(crate) mod fetcher_builtins { .map_err(|e| ErrorKind::TvixError(Rc::new(e)))? { Some(store_path) => { - let path = store_path.to_absolute_path().into(); - // TODO: add fetch to fetcher - drop(fetch); - - Ok(Value::Path(Box::new(path))) + // Move the fetch to KnownPaths, so it can be actually fetched later. + let sp = state + .known_paths + .borrow_mut() + .add_fetch(fetch, &name) + .expect("Tvix bug: should only fail if the store path cannot be calculated"); + + debug_assert_eq!( + sp, store_path, + "calculated store path by KnownPaths should match" + ); + + // Emit the calculated Store Path. + Ok(Value::Path(Box::new(store_path.to_absolute_path().into()))) } None => { // If we don't have enough info, do the fetch now. -- cgit 1.4.1