1use std::path::Path;
2
3use glob::Pattern;
4
5mod config;
6mod incremental;
7mod io;
8pub(crate) mod locking;
9
10pub use config::{CACHE_DIR_ENV_VAR, CacheConfig, DEFAULT_CACHE_DIR_NAME};
11pub use incremental::{
12 IncrementalManifest, IncrementalManifestEntry, incremental_manifest_path,
13 load_incremental_manifest, manifest_entry_matches_path, metadata_fingerprint,
14 write_incremental_manifest,
15};
16
17pub fn build_collection_exclude_patterns(scan_root: &Path, cache_root: &Path) -> Vec<Pattern> {
18 let mut patterns = Vec::new();
19
20 if let Ok(relative_cache_root) = cache_root.strip_prefix(scan_root)
21 && !relative_cache_root.as_os_str().is_empty()
22 {
23 for path in [cache_root.to_path_buf(), relative_cache_root.to_path_buf()] {
24 let normalized = path.to_string_lossy().replace('\\', "/");
25 let escaped = Pattern::escape(&normalized);
26 for pattern in [escaped.clone(), format!("{escaped}/**")] {
27 if let Ok(pattern) = Pattern::new(&pattern) {
28 patterns.push(pattern);
29 }
30 }
31 }
32 }
33
34 patterns
35}