From a73fd83dc9556d1172f73ead2258fb127e36bb56 Mon Sep 17 00:00:00 2001 From: Andrew Chambers Date: Mon, 21 Nov 2022 18:19:15 +0900 Subject: [PATCH] Fix index paths during put of paths in '/'. --- src/indexer.rs | 9 ++++++--- src/main.rs | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/indexer.rs b/src/indexer.rs index 38a95b9..2df08d7 100644 --- a/src/indexer.rs +++ b/src/indexer.rs @@ -464,9 +464,12 @@ impl MetadataCollector { PathBuf::from(path.file_name().unwrap()) } } else { - PathBuf::from(OsString::from_vec( - path_bytes[base_path_bytes.len() + 1..].to_vec(), - )) + let trim = if base_path_bytes.len() == 1 { + 1 // '/' is our base path, trim a single slash. + } else { + base_path_bytes.len() + 1 // Trim the base path and the separating '/'. + }; + PathBuf::from(OsString::from_vec(path_bytes[trim..].to_vec())) } }; diff --git a/src/main.rs b/src/main.rs index 18c2731..9d45ebe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2689,7 +2689,8 @@ fn indexer_benchmark_main(args: Vec) -> Result<(), anyhow::Error> { let indexer = indexer::FsIndexer::new(&dirs, indexer_opts).unwrap(); for ent in indexer { - println!("{}", ent?.0.display()); + let ent = ent?; + println!("{}: {}", ent.0.display(), ent.1.path.display()); } Ok(())