fix check file not found use is_err_object_not_found

This commit is contained in:
weisd
2024-12-23 15:44:24 +08:00
parent a40c2e2978
commit b46a78fb63
4 changed files with 15 additions and 7 deletions
+2 -1
View File
@@ -7,6 +7,7 @@ use std::{
time::Duration,
};
use ecstore::store_err::is_err_object_not_found;
use log::debug;
use time::OffsetDateTime;
use tokio::{
@@ -113,7 +114,7 @@ where
async fn save_iam_formatter(self: Arc<Self>) -> crate::Result<()> {
match self.api.load_iam_config::<Format>(Format::PATH).await {
Ok((format, _)) if format.version >= 1 => return Ok(()),
Err(Error::EcstoreError(e)) if !ecstore::disk::error::is_err_file_not_found(&e) => {
Err(Error::EcstoreError(e)) if !is_err_object_not_found(&e) => {
return Err(Error::EcstoreError(e));
}
_ => {}
+7 -2
View File
@@ -60,8 +60,13 @@ impl ObjectStore {
match items {
Ok(items) => Result::<_, crate::Error>::Ok(items.prefixes),
Err(e) if is_not_found(&e) => Result::<_, crate::Error>::Ok(vec![]),
Err(e) => Err(Error::StringError(format!("list {prefix} failed, err: {e:?}"))),
Err(e) => {
if is_not_found(&e) {
Result::<_, crate::Error>::Ok(vec![])
} else {
Err(Error::StringError(format!("list {prefix} failed, err: {e:?}")))
}
}
}
});
}