From 215355ea337140d7b5bfaaece3cc0b1dd2c71663 Mon Sep 17 00:00:00 2001 From: Aria Shrimpton Date: Tue, 23 Jan 2024 13:24:36 +0000 Subject: more efficient caching of profiling information --- src/crates/candelabra/src/cache.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/crates') diff --git a/src/crates/candelabra/src/cache.rs b/src/crates/candelabra/src/cache.rs index ccb61fd..4546fbe 100644 --- a/src/crates/candelabra/src/cache.rs +++ b/src/crates/candelabra/src/cache.rs @@ -121,12 +121,27 @@ pub fn gen_tree_hash(dir: &Utf8Path) -> Result { // TODO: ignore target, etc let mut hasher = DefaultHasher::new(); - for f in glob(&format!("{}/**/*", dir)).unwrap() { - let f = f?; - let as_str = f.as_os_str().to_str().unwrap(); - if as_str.contains("target/") || as_str.contains(".pr.rs") { + let mut files = glob(&format!("{}/**/*", dir)) + .unwrap() + .map(|r| r.map(|p| Utf8PathBuf::from_path_buf(p).unwrap())) + .collect::, _>>()?; + + // remove target/ + files.retain(|p| !p.as_str().contains("target/")); + + // ignore files generated by primrose + let ignore = files + .iter() + .filter(|p| p.as_str().contains(".pr.rs")) + .map(|p| Utf8PathBuf::from(p.to_string().replace(".pr.rs", ""))) + .collect::>(); + + // actual hashing + for f in files { + if ignore.contains(&f) { continue; } + dbg!(&f); let modified = metadata(f)?.modified()?; modified.hash(&mut hasher); -- cgit v1.2.3