fix(ecstore): resolve clippy warnings for io_other_error

This commit is contained in:
overtrue
2025-06-10 22:29:03 +08:00
parent 98ce64aaae
commit e40562b03d
+19 -28
View File
@@ -20,30 +20,24 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<Info> {
let reserved = match bfree.checked_sub(bavail) { let reserved = match bfree.checked_sub(bavail) {
Some(reserved) => reserved, Some(reserved) => reserved,
None => { None => {
return Err(Error::new( return Err(Error::other(format!(
ErrorKind::Other, "detected f_bavail space ({}) > f_bfree space ({}), fs corruption at ({}). please run 'fsck'",
format!( bavail,
"detected f_bavail space ({}) > f_bfree space ({}), fs corruption at ({}). please run 'fsck'", bfree,
bavail, p.as_ref().display()
bfree, )));
p.as_ref().display()
),
));
} }
}; };
let total = match blocks.checked_sub(reserved) { let total = match blocks.checked_sub(reserved) {
Some(total) => total * bsize, Some(total) => total * bsize,
None => { None => {
return Err(Error::new( return Err(Error::other(format!(
ErrorKind::Other, "detected reserved space ({}) > blocks space ({}), fs corruption at ({}). please run 'fsck'",
format!( reserved,
"detected reserved space ({}) > blocks space ({}), fs corruption at ({}). please run 'fsck'", blocks,
reserved, p.as_ref().display()
blocks, )));
p.as_ref().display()
),
));
} }
}; };
@@ -51,15 +45,12 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<Info> {
let used = match total.checked_sub(free) { let used = match total.checked_sub(free) {
Some(used) => used, Some(used) => used,
None => { None => {
return Err(Error::new( return Err(Error::other(format!(
ErrorKind::Other, "detected free space ({}) > total drive space ({}), fs corruption at ({}). please run 'fsck'",
format!( free,
"detected free space ({}) > total drive space ({}), fs corruption at ({}). please run 'fsck'", total,
free, p.as_ref().display()
total, )));
p.as_ref().display()
),
));
} }
}; };
@@ -121,7 +112,7 @@ pub fn get_drive_stats(major: u32, minor: u32) -> Result<IOStats> {
fn read_drive_stats(stats_file: &str) -> Result<IOStats> { fn read_drive_stats(stats_file: &str) -> Result<IOStats> {
let stats = read_stat(stats_file)?; let stats = read_stat(stats_file)?;
if stats.len() < 11 { if stats.len() < 11 {
return Err(Error::new(ErrorKind::Other, format!("found invalid format while reading {}", stats_file))); return Err(Error::other(format!("found invalid format while reading {}", stats_file)));
} }
let mut io_stats = IOStats { let mut io_stats = IOStats {
read_ios: stats[0], read_ios: stats[0],