refactor(filemeta): FileInfo data use Bytes

This commit is contained in:
Nugine
2025-06-15 21:01:38 +08:00
parent 3a567768c1
commit 8309d2f8be
3 changed files with 10 additions and 6 deletions
+2 -2
View File
@@ -168,13 +168,13 @@ pub struct FileInfo {
pub mark_deleted: bool,
// ReplicationState - Internal replication state to be passed back in ObjectInfo
// pub replication_state: Option<ReplicationState>, // TODO: implement ReplicationState
pub data: Option<Vec<u8>>,
pub data: Option<Bytes>,
pub num_versions: usize,
pub successor_mod_time: Option<OffsetDateTime>,
pub fresh: bool,
pub idx: usize,
// Combined checksum when object was uploaded
pub checksum: Option<Vec<u8>>,
pub checksum: Option<Bytes>,
pub versioned: bool,
}
+5 -2
View File
@@ -419,7 +419,7 @@ impl FileMeta {
if let Some(ref data) = fi.data {
let key = vid.unwrap_or_default().to_string();
self.data.replace(&key, data.clone())?;
self.data.replace(&key, data.to_vec())?;
}
let version = FileMetaVersion::from(fi);
@@ -543,7 +543,10 @@ impl FileMeta {
}
if read_data {
fi.data = self.data.find(fi.version_id.unwrap_or_default().to_string().as_str())?;
fi.data = self
.data
.find(fi.version_id.unwrap_or_default().to_string().as_str())?
.map(bytes::Bytes::from);
}
fi.num_versions = self.versions.len();