Skip to content

Commit 9b2774c

Browse files
committed
refactor
1 parent 2a67bb4 commit 9b2774c

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Diff for: src/info/repo.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,13 @@ impl<'a> Repo<'a> {
148148

149149
// This collects the repo size excluding .git
150150
pub fn get_repo_size(&self) -> (String, u64) {
151-
let (repo_size, file_count) = self
152-
.repo
153-
.load_index()
154-
.transpose()
155-
.ok()
156-
.flatten()
157-
.map(|index| {
151+
let (repo_size, file_count) = match self.repo.load_index() {
152+
Some(Ok(index)) => {
158153
let repo_size = index.entries().iter().map(|e| e.stat.size as u128).sum();
159154
(repo_size, index.entries().len() as u64)
160-
})
161-
.unwrap_or_default();
155+
}
156+
_ => (0, 0),
157+
};
162158

163159
(bytes_to_human_readable(repo_size), file_count)
164160
}

0 commit comments

Comments
 (0)