|
|
@ -33,15 +33,14 @@ pub async fn get_folder_size(path: PathBuf) -> RepoResult<u64> {
|
|
|
|
|
|
|
|
|
|
|
|
while !unchecked_dirs.is_empty() {
|
|
|
|
while !unchecked_dirs.is_empty() {
|
|
|
|
let dir = unchecked_dirs.remove(0);
|
|
|
|
let dir = unchecked_dirs.remove(0);
|
|
|
|
let mut read_dir = fs::read_dir(dir).await?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while let Some(entry) = read_dir.next_entry().await? {
|
|
|
|
match get_files_and_dirs_for_dir(&dir).await {
|
|
|
|
let file_type = entry.file_type().await?;
|
|
|
|
Ok((mut files, mut dirs)) => {
|
|
|
|
|
|
|
|
all_files.append(&mut files);
|
|
|
|
if file_type.is_file() {
|
|
|
|
unchecked_dirs.append(&mut dirs);
|
|
|
|
all_files.push(entry.path());
|
|
|
|
}
|
|
|
|
} else if file_type.is_dir() {
|
|
|
|
Err(e) => {
|
|
|
|
unchecked_dirs.push(entry.path())
|
|
|
|
tracing::warn!("failed to read entries for directory {:?}: {}", dir, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -56,6 +55,25 @@ pub async fn get_folder_size(path: PathBuf) -> RepoResult<u64> {
|
|
|
|
Ok(size)
|
|
|
|
Ok(size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async fn get_files_and_dirs_for_dir(dir: &PathBuf) -> RepoResult<(Vec<PathBuf>, Vec<PathBuf>)> {
|
|
|
|
|
|
|
|
let mut files = Vec::new();
|
|
|
|
|
|
|
|
let mut directories = Vec::new();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut read_dir = fs::read_dir(dir).await?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while let Some(entry) = read_dir.next_entry().await? {
|
|
|
|
|
|
|
|
let file_type = entry.file_type().await?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if file_type.is_file() {
|
|
|
|
|
|
|
|
files.push(entry.path());
|
|
|
|
|
|
|
|
} else if file_type.is_dir() {
|
|
|
|
|
|
|
|
directories.push(entry.path())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok((files, directories))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn read_file_size(path: PathBuf) -> RepoResult<u64> {
|
|
|
|
async fn read_file_size(path: PathBuf) -> RepoResult<u64> {
|
|
|
|
let metadata = fs::metadata(path).await?;
|
|
|
|
let metadata = fs::metadata(path).await?;
|
|
|
|
|
|
|
|
|
|
|
|