Skip to content

Commit d4bf0c1

Browse files
committed
fix(volume): use raw byte output from df
1 parent 680a78b commit d4bf0c1

2 files changed

Lines changed: 3 additions & 10 deletions

File tree

core/src/volume/platform/linux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub async fn detect_volumes(
3434
// Use df to get mounted filesystems
3535
let output = Command::new("df")
3636
.env("LC_ALL", "C")
37-
.args(["-h", "-T"]) // -T shows filesystem type
37+
.args(["-B1", "-T"]) // Use byte counts; -T shows filesystem type
3838
.output()
3939
.map_err(|e| VolumeError::platform(format!("Failed to run df: {}", e)))?;
4040

core/src/volume/utils.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ pub fn parse_size_string(size_str: &str) -> VolumeResult<u64> {
2222
return Ok(0);
2323
}
2424

25-
let size_str = if size_str.contains(',') && !size_str.contains('.') {
26-
size_str.replace(',', ".")
27-
} else {
28-
size_str.replace(',', "")
29-
};
25+
let size_str = size_str.replace(',', ""); // Remove grouping separators
3026
let (number_part, unit) = if let Some(pos) = size_str.find(char::is_alphabetic) {
3127
(&size_str[..pos], &size_str[pos..])
3228
} else {
@@ -340,10 +336,7 @@ mod tests {
340336
parse_size_string("1.5G").unwrap(),
341337
(1.5 * 1024.0 * 1024.0 * 1024.0) as u64
342338
);
343-
assert_eq!(
344-
parse_size_string("1,5G").unwrap(),
345-
(1.5 * 1024.0 * 1024.0 * 1024.0) as u64
346-
);
339+
assert_eq!(parse_size_string("1610612736").unwrap(), 1_610_612_736);
347340
assert_eq!(parse_size_string("-").unwrap(), 0);
348341
}
349342

0 commit comments

Comments
 (0)