From 82124fd0b946855254721117d7ba004c377d0f44 Mon Sep 17 00:00:00 2001 From: Wei Zhang Date: Sat, 28 Sep 2024 11:54:49 +0800 Subject: [PATCH] :bug: fix total size loop when using with -a --- src/git.rs | 2 +- src/meta/mod.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/git.rs b/src/git.rs index acc01108c..207da076d 100644 --- a/src/git.rs +++ b/src/git.rs @@ -181,7 +181,7 @@ mod tests { fn check_cache(root: &Path, statuses: &HashMap<&PathBuf, GitFileStatus>, msg: &str) { let cache = GitCache::new(root); for (&path, status) in statuses.iter() { - if let Ok(filename) = std::fs::canonicalize(&root.join(path)) { + if let Ok(filename) = std::fs::canonicalize(root.join(path)) { let is_directory = filename.is_dir(); assert_eq!( &cache.inner_get(&filename, is_directory), diff --git a/src/meta/mod.rs b/src/meta/mod.rs index 57ebbe45b..e8384fd19 100644 --- a/src/meta/mod.rs +++ b/src/meta/mod.rs @@ -201,6 +201,11 @@ impl Meta { None => 0, }; for x in &mut metas.iter_mut() { + // must not count the size of '.' and '..', or will be infinite loop + if x.name.name == "." || x.name.name == ".." { + continue; + } + x.calculate_total_size(); size_accumulated += match &x.size { Some(size) => size.get_bytes(),