Skip to content

Commit

Permalink
🐛 fix total size loop when using with -a
Browse files Browse the repository at this point in the history
  • Loading branch information
zwpaper committed Sep 28, 2024
1 parent ace462f commit 82124fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 5 additions & 0 deletions src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 82124fd

Please sign in to comment.