File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,15 @@ use walkdir::WalkDir;
44
55use super :: types:: { ArtifactCandidate , Size } ;
66
7+ pub fn total_size ( artifacts : & [ ArtifactCandidate ] ) -> u64 {
8+ artifacts. iter ( ) . fold ( 0 , |acc, artifact| {
9+ match & artifact. size {
10+ Size :: UnknownSize => acc,
11+ Size :: KnownSize ( size) => acc + size,
12+ }
13+ } )
14+ }
15+
716pub fn estimate ( artifact : & mut ArtifactCandidate ) -> & ArtifactCandidate {
817 let size = estimate_path ( & artifact. path ) ;
918 artifact. size = size;
@@ -18,7 +27,7 @@ fn estimate_path(path: &PathBuf) -> Size {
1827}
1928
2029fn calculate_dir_size ( path : & PathBuf ) -> std:: io:: Result < u64 > {
21- let mut total_size = 0 ;
30+ let mut total = 0 ;
2231
2332 for entry in WalkDir :: new ( path)
2433 . follow_links ( false )
@@ -27,11 +36,11 @@ fn calculate_dir_size(path: &PathBuf) -> std::io::Result<u64> {
2736 . filter ( |e| e. file_type ( ) . is_file ( ) )
2837 {
2938 if let Ok ( metadata) = fs:: metadata ( entry. path ( ) ) {
30- total_size += metadata. len ( ) ;
39+ total += metadata. len ( ) ;
3140 }
3241 }
3342
34- Ok ( total_size )
43+ Ok ( total )
3544}
3645
3746#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments