File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments