diff --git a/fs-index/src/index.rs b/fs-index/src/index.rs index 0221d7a..9854bba 100644 --- a/fs-index/src/index.rs +++ b/fs-index/src/index.rs @@ -281,15 +281,20 @@ impl ResourceIndex { pub fn build>(root_path: P) -> Result { log::debug!("Building index at root path: {:?}", root_path.as_ref()); - // Canonicalize the root path - let root = fs::canonicalize(&root_path)?; + let root_path = root_path.as_ref(); + // Canonicalize the root path (only for unix-like systems) + // Note: On windows, canonicalization adds a prefix to the path + // which breaks the path comparison in the tests + #[cfg(target_family = "unix")] + let root_path = root_path.canonicalize()?; + let mut id_to_paths: HashMap> = HashMap::new(); let mut path_to_resource = HashMap::new(); // Discover paths in the root directory - let paths = discover_paths(&root)?; + let paths = discover_paths(&root_path)?; let entries: HashMap> = - scan_entries(&root, paths); + scan_entries(&root_path, paths); // Strip the root path from the entries let entries: HashMap> = entries @@ -309,7 +314,7 @@ impl ResourceIndex { path_to_resource.extend(entries.clone()); let index = ResourceIndex { - root, + root: root_path.to_path_buf(), id_to_paths, path_to_resource, }; diff --git a/fs-index/src/tests.rs b/fs-index/src/tests.rs index 7b3b0b3..89749cc 100644 --- a/fs-index/src/tests.rs +++ b/fs-index/src/tests.rs @@ -239,8 +239,6 @@ fn test_build_index_with_directory() { .expect("Failed to get resource"); assert_eq!( resource, expected_resource, - "{:?} != {:?}", - resource, expected_resource ); }); }