Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2026-01-25 19:55:43 +02:00
parent 98cede7854
commit 0a4c2fe3dc

View File

@@ -10,12 +10,8 @@ struct Args {
fn compute_size(path: PathBuf) -> Result<u64, std::io::Error> { fn compute_size(path: PathBuf) -> Result<u64, std::io::Error> {
if path.is_dir() { if path.is_dir() {
std::fs::read_dir(path)?.fold(Ok(0_u64), |counter, entry| -> Result<u64, std::io::Error> { std::fs::read_dir(path)?.try_fold(0_u64, |counter, entry| -> Result<u64, std::io::Error> {
if let Ok(counter) = counter {
Ok(counter + compute_size(entry?.path())?) Ok(counter + compute_size(entry?.path())?)
} else {
counter
}
}) })
} else { } else {
Ok(std::fs::metadata(path)?.len()) Ok(std::fs::metadata(path)?.len())