Skip to content

Commit 868f6e6

Browse files
committed
fix(volume): preserve exact byte counts with B suffix
1 parent 06d9070 commit 868f6e6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

core/src/volume/utils.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn parse_size_string(size_str: &str) -> VolumeResult<u64> {
4242

4343
// Linux `df -B1` emits integer byte counts. Parse those directly so values above
4444
// f64's exact-integer range retain all bits of precision.
45-
if unit.is_empty() && !number_part.contains('.') {
45+
if (unit.is_empty() || unit.eq_ignore_ascii_case("B")) && !number_part.contains('.') {
4646
return number_part
4747
.parse::<u64>()
4848
.map_err(|_| VolumeError::InvalidData(format!("Invalid size: {}", size_str)));
@@ -360,6 +360,10 @@ mod tests {
360360
parse_size_string("9007199254740993").unwrap(),
361361
9_007_199_254_740_993
362362
);
363+
assert_eq!(
364+
parse_size_string("9007199254740993B").unwrap(),
365+
9_007_199_254_740_993
366+
);
363367
assert_eq!(
364368
parse_size_string("1,5G").unwrap(),
365369
(1.5 * 1024.0 * 1024.0 * 1024.0) as u64

0 commit comments

Comments
 (0)