From 1efcce000156e81285c8a187569f9ebd681a5cb1 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 27 Jun 2025 22:59:34 +0800 Subject: [PATCH] fix --- crates/utils/src/os/linux.rs | 7 ++++--- crates/utils/src/os/unix.rs | 16 ++++------------ crates/utils/src/os/windows.rs | 6 ++---- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/crates/utils/src/os/linux.rs b/crates/utils/src/os/linux.rs index 01399aafe..5d2cb889a 100644 --- a/crates/utils/src/os/linux.rs +++ b/crates/utils/src/os/linux.rs @@ -8,6 +8,7 @@ use super::{DiskInfo, IOStats}; /// Returns total and free bytes available in a directory, e.g. `/`. pub fn get_info(p: impl AsRef) -> std::io::Result { + let path_display = p.as_ref().display(); let stat_fs = statfs(p.as_ref())?; let bsize = stat_fs.block_size() as u64; @@ -19,7 +20,7 @@ pub fn get_info(p: impl AsRef) -> std::io::Result { Some(reserved) => reserved, None => { return Err(Error::other(format!( - "detected f_bavail space ({bavail}) > f_bfree space ({bfree}), fs corruption at ({p.as_ref().display()}). please run 'fsck'" + "detected f_bavail space ({bavail}) > f_bfree space ({bfree}), fs corruption at ({path_display}). please run 'fsck'" ))); } }; @@ -28,7 +29,7 @@ pub fn get_info(p: impl AsRef) -> std::io::Result { Some(total) => total * bsize, None => { return Err(Error::other(format!( - "detected reserved space ({reserved}) > blocks space ({blocks}), fs corruption at ({p.as_ref().display()}). please run 'fsck'" + "detected reserved space ({reserved}) > blocks space ({blocks}), fs corruption at ({path_display}). please run 'fsck'" ))); } }; @@ -38,7 +39,7 @@ pub fn get_info(p: impl AsRef) -> std::io::Result { Some(used) => used, None => { return Err(Error::other(format!( - "detected free space ({free}) > total drive space ({total}), fs corruption at ({p.as_ref().display()}). please run 'fsck'" + "detected free space ({free}) > total drive space ({total}), fs corruption at ({path_display}). please run 'fsck'" ))); } }; diff --git a/crates/utils/src/os/unix.rs b/crates/utils/src/os/unix.rs index d1ec42c1d..40206f2a3 100644 --- a/crates/utils/src/os/unix.rs +++ b/crates/utils/src/os/unix.rs @@ -5,6 +5,7 @@ use std::path::Path; /// Returns total and free bytes available in a directory, e.g. `/`. pub fn get_info(p: impl AsRef) -> std::io::Result { + let path_display = p.as_ref().display(); let stat = statfs(p.as_ref())?; let bsize = stat.block_size() as u64; @@ -16,10 +17,7 @@ pub fn get_info(p: impl AsRef) -> std::io::Result { Some(reserved) => reserved, None => { return Err(Error::other(format!( - "detected f_bavail space ({}) > f_bfree space ({}), fs corruption at ({}). please run 'fsck'", - bavail, - bfree, - p.as_ref().display() + "detected f_bavail space ({bavail}) > f_bfree space ({bfree}), fs corruption at ({path_display}). please run 'fsck'", ))); } }; @@ -28,10 +26,7 @@ pub fn get_info(p: impl AsRef) -> std::io::Result { Some(total) => total * bsize, None => { return Err(Error::other(format!( - "detected reserved space ({}) > blocks space ({}), fs corruption at ({}). please run 'fsck'", - reserved, - blocks, - p.as_ref().display() + "detected reserved space ({reserved}) > blocks space ({blocks}), fs corruption at ({path_display}). please run 'fsck'", ))); } }; @@ -41,10 +36,7 @@ pub fn get_info(p: impl AsRef) -> std::io::Result { Some(used) => used, None => { return Err(Error::other(format!( - "detected free space ({}) > total drive space ({}), fs corruption at ({}). please run 'fsck'", - free, - total, - p.as_ref().display() + "detected free space ({free}) > total drive space ({total}), fs corruption at ({path_display}). please run 'fsck'" ))); } }; diff --git a/crates/utils/src/os/windows.rs b/crates/utils/src/os/windows.rs index 401165062..0791c8ae7 100644 --- a/crates/utils/src/os/windows.rs +++ b/crates/utils/src/os/windows.rs @@ -12,6 +12,7 @@ use winapi::um::winnt::{LPCWSTR, WCHAR}; /// Returns total and free bytes available in a directory, e.g. `C:\`. pub fn get_info(p: impl AsRef) -> std::io::Result { + let path_display = p.as_ref().display(); let path_wide: Vec = p .as_ref() .canonicalize()? @@ -41,10 +42,7 @@ pub fn get_info(p: impl AsRef) -> std::io::Result { if free > total { return Err(Error::other(format!( - "detected free space ({}) > total drive space ({}), fs corruption at ({}). please run 'fsck'", - free, - total, - p.as_ref().display() + "detected free space ({free}) > total drive space ({total}), fs corruption at ({path_display}). please run 'fsck'" ))); }