feat: progression status for copy I/O in Tasks window

This commit is contained in:
Seno Pamungkas 2025-08-29 15:05:58 +07:00 committed by sxyazi
parent b997e56a60
commit 7aa5f18b41
No known key found for this signature in database
2 changed files with 17 additions and 1 deletions

View file

@ -9,3 +9,19 @@ impl BytesExt for [u8] {
Some((left, &right[sep.len()..]))
}
}
pub fn human_bytes(n: u64) -> String {
const KB: f64 = 1024.0;
const MB: f64 = KB * 1024.0;
const GB: f64 = MB * 1024.0;
let x = n as f64;
if x >= GB {
format!("{:.2} GB", x / GB)
} else if x >= MB {
format!("{:.2} MB", x / MB)
} else if x >= KB {
format!("{:.2} KB", x / KB)
} else {
format!("{n} B")
}
}

View file

@ -339,7 +339,7 @@ mod tests {
for (path, expected) in cases {
let path: UrlBuf = path.parse()?;
assert_eq!(path.parent().map(|u| format!("{:?}", u)).as_deref(), expected);
assert_eq!(path.parent().map(|u| format!("{u:?}")).as_deref(), expected);
}
Ok(())