mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
refactor(filemeta): FileInfo data use Bytes
This commit is contained in:
@@ -168,13 +168,13 @@ pub struct FileInfo {
|
|||||||
pub mark_deleted: bool,
|
pub mark_deleted: bool,
|
||||||
// ReplicationState - Internal replication state to be passed back in ObjectInfo
|
// ReplicationState - Internal replication state to be passed back in ObjectInfo
|
||||||
// pub replication_state: Option<ReplicationState>, // TODO: implement ReplicationState
|
// pub replication_state: Option<ReplicationState>, // TODO: implement ReplicationState
|
||||||
pub data: Option<Vec<u8>>,
|
pub data: Option<Bytes>,
|
||||||
pub num_versions: usize,
|
pub num_versions: usize,
|
||||||
pub successor_mod_time: Option<OffsetDateTime>,
|
pub successor_mod_time: Option<OffsetDateTime>,
|
||||||
pub fresh: bool,
|
pub fresh: bool,
|
||||||
pub idx: usize,
|
pub idx: usize,
|
||||||
// Combined checksum when object was uploaded
|
// Combined checksum when object was uploaded
|
||||||
pub checksum: Option<Vec<u8>>,
|
pub checksum: Option<Bytes>,
|
||||||
pub versioned: bool,
|
pub versioned: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ impl FileMeta {
|
|||||||
|
|
||||||
if let Some(ref data) = fi.data {
|
if let Some(ref data) = fi.data {
|
||||||
let key = vid.unwrap_or_default().to_string();
|
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);
|
let version = FileMetaVersion::from(fi);
|
||||||
@@ -543,7 +543,10 @@ impl FileMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if read_data {
|
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();
|
fi.num_versions = self.versions.len();
|
||||||
|
|||||||
@@ -2594,7 +2594,8 @@ impl SetDisks {
|
|||||||
// if let Some(w) = writer.as_any().downcast_ref::<BitrotFileWriter>() {
|
// if let Some(w) = writer.as_any().downcast_ref::<BitrotFileWriter>() {
|
||||||
// parts_metadata[index].data = Some(w.inline_data().to_vec());
|
// parts_metadata[index].data = Some(w.inline_data().to_vec());
|
||||||
// }
|
// }
|
||||||
parts_metadata[index].data = Some(writer.into_inline_data().unwrap_or_default());
|
parts_metadata[index].data =
|
||||||
|
Some(writer.into_inline_data().map(bytes::Bytes::from).unwrap_or_default());
|
||||||
}
|
}
|
||||||
parts_metadata[index].set_inline_data();
|
parts_metadata[index].set_inline_data();
|
||||||
} else {
|
} else {
|
||||||
@@ -3920,7 +3921,7 @@ impl ObjectIO for SetDisks {
|
|||||||
for (i, fi) in parts_metadatas.iter_mut().enumerate() {
|
for (i, fi) in parts_metadatas.iter_mut().enumerate() {
|
||||||
if is_inline_buffer {
|
if is_inline_buffer {
|
||||||
if let Some(writer) = writers[i].take() {
|
if let Some(writer) = writers[i].take() {
|
||||||
fi.data = Some(writer.into_inline_data().unwrap_or_default());
|
fi.data = Some(writer.into_inline_data().map(bytes::Bytes::from).unwrap_or_default());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user