Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Mar 30, 2022
1 parent 2a67bb4 commit 9b2774c
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/info/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,13 @@ impl<'a> Repo<'a> {

// This collects the repo size excluding .git
pub fn get_repo_size(&self) -> (String, u64) {
let (repo_size, file_count) = self
.repo
.load_index()
.transpose()
.ok()
.flatten()
.map(|index| {
let (repo_size, file_count) = match self.repo.load_index() {
Some(Ok(index)) => {
let repo_size = index.entries().iter().map(|e| e.stat.size as u128).sum();
(repo_size, index.entries().len() as u64)
})
.unwrap_or_default();
}
_ => (0, 0),
};

(bytes_to_human_readable(repo_size), file_count)
}
Expand Down

0 comments on commit 9b2774c

Please sign in to comment.