MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / calculate_folder_size

Function calculate_folder_size

src/upload/uploader.rs:35–53  ·  view source on GitHub ↗

Calculate the total size of a directory in bytes

(path: &std::path::Path)

Source from the content-addressed store, hash-verified

33
34/// Calculate the total size of a directory in bytes
35async fn calculate_folder_size(path: &std::path::Path) -> Result<u64> {
36 let mut total_size = 0u64;
37 let mut dirs_to_process = vec![path.to_path_buf()];
38
39 while let Some(current_dir) = dirs_to_process.pop() {
40 let mut entries = tokio::fs::read_dir(&current_dir).await?;
41
42 while let Some(entry) = entries.next_entry().await? {
43 let metadata = entry.metadata().await?;
44 if metadata.is_file() {
45 total_size += metadata.len();
46 } else if metadata.is_dir() {
47 dirs_to_process.push(entry.path());
48 }
49 }
50 }
51
52 Ok(total_size)
53}
54
55/// Create a profile archive from the profile folder and return its md5 hash encoded in base64
56///

Callers 1

create_profile_archiveFunction · 0.85

Calls 1

pathMethod · 0.80

Tested by

no test coverage detected