diff options
author | Vincent Ambo <mail@tazj.in> | 2023-02-02T21·20+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2023-02-02T23·37+0000 |
commit | 38e8c2e95931673deb7cb939a05ac9bdaf305340 (patch) | |
tree | 42acefda078647e1b8dfcd9173b43a42beff85ee /tvix/cli/src/refscan.rs | |
parent | e6235e2932cc76b18fe8cc8acf209c5fe2e8b79f (diff) |
fix(tvix/cli): keep tracking full paths in known_paths r/5827
We need to distinguish explicitly between the paths used for the scanner, and the paths that populate the derivation inputs. The full paths must be accessible from the result of the refscanner to populate drv fields correctly. This was previously hidden by debug changes that masked actual IO operations with no-ops. Change-Id: I037af6e6bbe2b573034d695f8779bee1b56bc125 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8022 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/cli/src/refscan.rs')
-rw-r--r-- | tvix/cli/src/refscan.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/tvix/cli/src/refscan.rs b/tvix/cli/src/refscan.rs index 4314e0164429..567a677ce15d 100644 --- a/tvix/cli/src/refscan.rs +++ b/tvix/cli/src/refscan.rs @@ -14,16 +14,16 @@ pub const STORE_PATH_LEN: usize = "/nix/store/00000000000000000000000000000000". /// Represents a "primed" reference scanner with an automaton that knows the set /// of store paths to scan for. -pub struct ReferenceScanner { - candidates: Vec<String>, +pub struct ReferenceScanner<P: Ord + AsRef<[u8]>> { + candidates: Vec<P>, searcher: TwoByteWM, matches: Vec<usize>, } -impl ReferenceScanner { +impl<P: Clone + Ord + AsRef<[u8]>> ReferenceScanner<P> { /// Construct a new `ReferenceScanner` that knows how to scan for the given /// candidate store paths. - pub fn new(candidates: Vec<String>) -> Self { + pub fn new(candidates: Vec<P>) -> Self { let searcher = TwoByteWM::new(&candidates); ReferenceScanner { @@ -46,7 +46,7 @@ impl ReferenceScanner { } /// Finalise the reference scanner and return the resulting matches. - pub fn finalise(self) -> BTreeSet<String> { + pub fn finalise(self) -> BTreeSet<P> { self.matches .into_iter() .map(|idx| self.candidates[idx].clone()) @@ -64,7 +64,7 @@ mod tests { #[test] fn test_single_match() { let mut scanner = ReferenceScanner::new(vec![ - "/nix/store/4xw8n979xpivdc46a9ndcvyhwgif00hz-bash-5.1-p16".into(), + "/nix/store/4xw8n979xpivdc46a9ndcvyhwgif00hz-bash-5.1-p16".to_string(), ]); scanner.scan_str(HELLO_DRV); @@ -78,11 +78,11 @@ mod tests { fn test_multiple_matches() { let candidates = vec![ // these exist in the drv: - "/nix/store/33l4p0pn0mybmqzaxfkpppyh7vx1c74p-hello-2.12.1".into(), - "/nix/store/pf80kikyxr63wrw56k00i1kw6ba76qik-hello-2.12.1.tar.gz.drv".into(), - "/nix/store/cp65c8nk29qq5cl1wyy5qyw103cwmax7-stdenv-linux".into(), + "/nix/store/33l4p0pn0mybmqzaxfkpppyh7vx1c74p-hello-2.12.1".to_string(), + "/nix/store/pf80kikyxr63wrw56k00i1kw6ba76qik-hello-2.12.1.tar.gz.drv".to_string(), + "/nix/store/cp65c8nk29qq5cl1wyy5qyw103cwmax7-stdenv-linux".to_string(), // this doesn't: - "/nix/store/fn7zvafq26f0c8b17brs7s95s10ibfzs-emacs-28.2.drv".into(), + "/nix/store/fn7zvafq26f0c8b17brs7s95s10ibfzs-emacs-28.2.drv".to_string(), ]; let mut scanner = ReferenceScanner::new(candidates.clone()); |