mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 08:18:18 +00:00
fix: restore bitrot stream and checksum metadata (#2542)
This commit is contained in:
@@ -64,7 +64,7 @@ pub async fn create_bitrot_reader(
|
||||
Ok(Some(reader))
|
||||
} else if let Some(disk) = disk {
|
||||
// Read from disk
|
||||
if use_zero_copy {
|
||||
if use_zero_copy && disk.is_local() {
|
||||
// Try zero-copy read first (uses mmap on Unix)
|
||||
let start = Instant::now();
|
||||
match disk.read_file_zero_copy(bucket, path, offset, length).await {
|
||||
|
||||
@@ -24,7 +24,7 @@ use rustfs_utils::http::headers::{
|
||||
AMZ_STORAGE_CLASS,
|
||||
};
|
||||
use rustfs_utils::http::{
|
||||
AMZ_BUCKET_REPLICATION_STATUS, SUFFIX_DATA_MOV, SUFFIX_HEALING, SUFFIX_PURGESTATUS, SUFFIX_REPLICA_STATUS,
|
||||
AMZ_BUCKET_REPLICATION_STATUS, SUFFIX_CRC, SUFFIX_DATA_MOV, SUFFIX_HEALING, SUFFIX_PURGESTATUS, SUFFIX_REPLICA_STATUS,
|
||||
SUFFIX_REPLICA_TIMESTAMP, SUFFIX_REPLICATION_STATUS, SUFFIX_REPLICATION_TIMESTAMP, has_internal_suffix, insert_bytes,
|
||||
is_internal_key,
|
||||
};
|
||||
@@ -233,6 +233,10 @@ impl FileMeta {
|
||||
if let Some(mod_time) = fi.mod_time {
|
||||
obj.mod_time = Some(mod_time);
|
||||
}
|
||||
|
||||
if let Some(content_hash) = fi.checksum.as_ref() {
|
||||
insert_bytes(&mut obj.meta_sys, SUFFIX_CRC, content_hash.to_vec());
|
||||
}
|
||||
}
|
||||
|
||||
// Update
|
||||
@@ -1721,6 +1725,30 @@ mod test {
|
||||
assert_eq!(after, Some(Bytes::from_static(b"inline").to_vec()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_update_object_version_persists_checksum_metadata() {
|
||||
let mut fm = FileMeta::new();
|
||||
let version_id = Some(Uuid::new_v4());
|
||||
|
||||
let mut fi = crate::fileinfo::FileInfo::new("test", 2, 1);
|
||||
fi.version_id = version_id;
|
||||
fi.mod_time = Some(OffsetDateTime::now_utc());
|
||||
fm.add_version(fi).unwrap();
|
||||
|
||||
let checksum = Bytes::from_static(b"resolved-checksum");
|
||||
let mut update = crate::fileinfo::FileInfo::new("test", 2, 1);
|
||||
update.version_id = version_id;
|
||||
update.metadata.insert("x-amz-meta-owner".to_string(), "alice".to_string());
|
||||
update.checksum = Some(checksum.clone());
|
||||
|
||||
fm.update_object_version(update).unwrap();
|
||||
|
||||
let (_, version) = fm.find_version(version_id).unwrap();
|
||||
let stored = version.into_fileinfo("bucket", "test", true);
|
||||
assert_eq!(stored.metadata.get("x-amz-meta-owner"), Some(&"alice".to_string()));
|
||||
assert_eq!(stored.checksum, Some(checksum));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_version_merge_scenarios() {
|
||||
// Test various version merge scenarios
|
||||
|
||||
Reference in New Issue
Block a user