添加 自定义MetaObject marshal

This commit is contained in:
weisd
2024-08-13 14:32:32 +08:00
parent d1b1e896f6
commit 278aae8fff
5 changed files with 81 additions and 77 deletions
+18 -9
View File
@@ -28,7 +28,7 @@ pub struct LocalDisk {
pub _format_meta: Option<Metadata>,
pub _format_path: PathBuf,
// pub format_legacy: bool, // drop
pub _format_last_check: OffsetDateTime,
pub _format_last_check: Option<OffsetDateTime>,
}
impl LocalDisk {
@@ -48,7 +48,7 @@ impl LocalDisk {
let mut id = Uuid::nil();
// let mut format_legacy = false;
let mut format_last_check = OffsetDateTime::UNIX_EPOCH;
let mut format_last_check = None;
if !format_data.is_empty() {
let s = format_data.as_slice();
@@ -61,7 +61,7 @@ impl LocalDisk {
id = fm.erasure.this;
// format_legacy = fm.erasure.distribution_algo == DistributionAlgoVersion::V1;
format_last_check = OffsetDateTime::now_utc();
format_last_check = Some(OffsetDateTime::now_utc());
}
let disk = Self {
@@ -619,8 +619,11 @@ impl DiskAPI for LocalDisk {
let name = entry.file_name().to_string_lossy().to_string();
let created = match metadata.created() {
Ok(md) => OffsetDateTime::from(md),
Err(_) => return Err(Error::msg("Not supported created on this platform")),
Ok(md) => Some(OffsetDateTime::from(md)),
Err(_) => {
warn!("Not supported created on this platform");
None
}
};
volumes.push(VolumeInfo { name, created });
@@ -634,8 +637,11 @@ impl DiskAPI for LocalDisk {
let m = read_file_metadata(&p).await?;
let modtime = match m.modified() {
Ok(md) => OffsetDateTime::from(md),
Err(_) => return Err(Error::msg("Not supported modified on this platform")),
Ok(md) => Some(OffsetDateTime::from(md)),
Err(_) => {
warn!("Not supported modified on this platform");
None
}
};
Ok(VolumeInfo {
@@ -722,8 +728,11 @@ impl DiskAPI for LocalDisk {
res.exists = true;
res.data = data;
res.mod_time = match meta.modified() {
Ok(md) => OffsetDateTime::from(md),
Err(_) => return Err(Error::msg("Not supported modified on this platform")),
Ok(md) => Some(OffsetDateTime::from(md)),
Err(_) => {
warn!("Not supported modified on this platform");
None
}
};
results.push(res);
+16 -16
View File
@@ -107,7 +107,7 @@ pub struct ReadMultipleReq {
pub max_results: usize,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct ReadMultipleResp {
pub bucket: String,
pub prefix: String,
@@ -115,26 +115,26 @@ pub struct ReadMultipleResp {
pub exists: bool,
pub error: String,
pub data: Vec<u8>,
pub mod_time: OffsetDateTime,
pub mod_time: Option<OffsetDateTime>,
}
impl Default for ReadMultipleResp {
fn default() -> Self {
Self {
bucket: String::new(),
prefix: String::new(),
file: String::new(),
exists: false,
error: String::new(),
data: Vec::new(),
mod_time: OffsetDateTime::UNIX_EPOCH,
}
}
}
// impl Default for ReadMultipleResp {
// fn default() -> Self {
// Self {
// bucket: String::new(),
// prefix: String::new(),
// file: String::new(),
// exists: false,
// error: String::new(),
// data: Vec::new(),
// mod_time: OffsetDateTime::UNIX_EPOCH,
// }
// }
// }
pub struct VolumeInfo {
pub name: String,
pub created: OffsetDateTime,
pub created: Option<OffsetDateTime>,
}
pub struct ReadOptions {