diff options
Diffstat (limited to 'tvix/cli/src/known_paths.rs')
-rw-r--r-- | tvix/cli/src/known_paths.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tvix/cli/src/known_paths.rs b/tvix/cli/src/known_paths.rs index 165bc3ea4161..69651d418069 100644 --- a/tvix/cli/src/known_paths.rs +++ b/tvix/cli/src/known_paths.rs @@ -11,7 +11,7 @@ //! Please see //tvix/eval/docs/build-references.md for more //! information. -use crate::refscan::ReferenceScanner; +use crate::refscan::{ReferenceScanner, STORE_PATH_LEN}; use std::{ collections::{hash_map, BTreeSet, HashMap}, ops::Index, @@ -45,12 +45,14 @@ impl Index<&str> for KnownPaths { type Output = PathType; fn index(&self, index: &str) -> &Self::Output { - &self.paths[index] + &self.paths[&index[..STORE_PATH_LEN]] } } impl KnownPaths { fn insert_path(&mut self, path: String, path_type: PathType) { + let path = path[..STORE_PATH_LEN].to_owned(); + assert_eq!(path.len(), STORE_PATH_LEN, "should match"); match self.paths.entry(path) { hash_map::Entry::Vacant(entry) => { entry.insert(path_type); @@ -108,6 +110,12 @@ impl KnownPaths { ); } + /// Checks whether there are any known paths. If not, a reference + /// scanner can not be created. + pub fn is_empty(&self) -> bool { + self.paths.is_empty() + } + /// Create a reference scanner from the current set of known paths. pub fn reference_scanner(&self) -> ReferenceScanner { let candidates = self.paths.keys().map(Clone::clone).collect(); |