Cross platform get_info

Signed-off-by: junxiang Mu <1948535941@qq.com>
This commit is contained in:
junxiang Mu
2024-10-22 14:31:28 +08:00
parent 9ff243a7a9
commit 49593dd77d
12 changed files with 281 additions and 10 deletions
+17
View File
@@ -401,3 +401,20 @@ pub fn convert_access_error(e: io::Error, per_err: DiskError) -> Error {
Error::new(e)
}
pub fn is_all_not_found(errs: &[Option<Error>]) -> bool {
for err in errs.iter() {
if let Some(err) = err {
if let Some(err) = err.downcast_ref::<DiskError>() {
match err {
DiskError::FileNotFound | DiskError::VolumeNotFound | &DiskError::FileVersionNotFound =>{
continue;
},
_ => return false,
}
}
}
}
!errs.is_empty()
}
+1 -1
View File
@@ -17,7 +17,7 @@ use crate::error::{Error, Result};
use crate::global::{GLOBAL_IsErasureSD, GLOBAL_RootDiskThreshold};
use crate::utils::fs::{lstat, O_APPEND, O_CREATE, O_RDONLY, O_WRONLY};
use crate::utils::path::{clean, has_suffix, SLASH_SEPARATOR};
use crate::utils::stat_linux::get_info;
use crate::utils::os::get_info;
use crate::{
file_meta::FileMeta,
store_api::{FileInfo, RawFileInfo},
+1 -1
View File
@@ -8,7 +8,7 @@ use tokio::fs;
use crate::{
disk::error::{is_sys_err_not_dir, is_sys_err_path_not_found, os_is_not_exist},
error::{Error, Result},
utils::{self, stat_linux::same_disk},
utils::{self, os::same_disk},
};
use super::error::{os_err_to_file_err, os_is_exist, DiskError};