mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: progression status for copy I/O in Tasks window
This commit is contained in:
parent
b997e56a60
commit
7aa5f18b41
2 changed files with 17 additions and 1 deletions
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue