@@ -68,21 +68,7 @@ impl ArtifactBuilder<CardanoDbBeacon, CardanoDatabaseSnapshot> for CardanoDataba
68
68
}
69
69
}
70
70
71
- /// Return the sum of the files size contained in the subdirectories 'immutable', 'ledger' and 'volatile'.
72
- fn compute_uncompressed_database_size ( db_directory : & Path ) -> StdResult < u64 > {
73
- let subdirs = [ "immutable" , "ledger" , "volatile" ] ;
74
-
75
- subdirs
76
- . iter ( )
77
- . map ( |subdir| {
78
- let dir_path = db_directory. join ( subdir) ;
79
- compute_fs_entry_size ( & dir_path)
80
- . with_context ( || format ! ( "Failed to read metadata for directory: {:?}" , dir_path) )
81
- } )
82
- . sum ( )
83
- }
84
-
85
- fn compute_fs_entry_size ( path : & Path ) -> StdResult < u64 > {
71
+ fn compute_uncompressed_database_size ( path : & Path ) -> StdResult < u64 > {
86
72
if path. is_file ( ) {
87
73
let metadata = std:: fs:: metadata ( path)
88
74
. with_context ( || format ! ( "Failed to read metadata for file: {:?}" , path) ) ?;
@@ -98,7 +84,7 @@ fn compute_fs_entry_size(path: &Path) -> StdResult<u64> {
98
84
let path = entry
99
85
. with_context ( || format ! ( "Failed to read directory entry in {:?}" , path) ) ?
100
86
. path ( ) ;
101
- directory_size += compute_fs_entry_size ( & path) ?;
87
+ directory_size += compute_uncompressed_database_size ( & path) ?;
102
88
}
103
89
104
90
return Ok ( directory_size) ;
@@ -142,15 +128,6 @@ mod tests {
142
128
let expected_total_size =
143
129
( 2 * 3 * immutable_file_size) + ledger_file_size + ( 2 * volatile_file_size) ;
144
130
145
- std:: fs:: write ( test_dir. join ( "non_computed_file.txt" ) , "file inside root" ) . unwrap ( ) ;
146
- let non_computed_dir = test_dir. join ( "non_computed_dir" ) ;
147
- std:: fs:: create_dir ( & non_computed_dir) . unwrap ( ) ;
148
- std:: fs:: write (
149
- non_computed_dir. join ( "another_non_computed_file.txt" ) ,
150
- "file inside a non computed directory" ,
151
- )
152
- . unwrap ( ) ;
153
-
154
131
let total_size = compute_uncompressed_database_size ( & test_dir) . unwrap ( ) ;
155
132
156
133
assert_eq ! ( expected_total_size, total_size) ;
0 commit comments