mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 08:18:18 +00:00
feat(rio): rio_v2 is compatible with minio for storing data. (#3115)
* Set up a compatibility layer for replacing old Rio components with new ones. * fix(rio). compress range * feat(rio). Add the experimental feature rio_v2 to support minio data at the binary level. * feat(rio_v2): add sse-c test * test compression component * simple fix * fix minlz encode * fix metadata * fix kms key cache error * Update launch.json * ci: set nix crate download user agent * fix: gate obs pyroscope backend * ignore minio test * fix encrypt check * fix * fix * fix * Update object_usecase.rs * Update ci.yml * fix * ci add rio-v2 test * fix * ci fix * fix * Reconstructed into a more reasonable compatibility mode * fix * fix --------- Signed-off-by: houseme <housemecn@gmail.com> Signed-off-by: 唐小鸭 <tangtang1251@qq.com> Co-authored-by: houseme <housemecn@gmail.com> Co-authored-by: cxymds <Cxymds@qq.com> Co-authored-by: 安正超 <anzhengchao@gmail.com>
This commit is contained in:
@@ -112,18 +112,27 @@ pub fn insert_str(map: &mut HashMap<String, String>, suffix: &str, value: String
|
||||
|
||||
pub fn get_str(map: &HashMap<String, String>, suffix: &str) -> Option<String> {
|
||||
let (k1, k2) = both_keys(suffix);
|
||||
map.get(&k1).cloned().or_else(|| map.get(&k2).cloned())
|
||||
map.get(&k1).cloned().or_else(|| map.get(&k2).cloned()).or_else(|| {
|
||||
map.iter()
|
||||
.find(|(key, _)| key.eq_ignore_ascii_case(&k1) || key.eq_ignore_ascii_case(&k2))
|
||||
.map(|(_, value)| value.clone())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn contains_key_str(map: &HashMap<String, String>, suffix: &str) -> bool {
|
||||
let (k1, k2) = both_keys(suffix);
|
||||
map.contains_key(&k1) || map.contains_key(&k2)
|
||||
map.contains_key(&k1)
|
||||
|| map.contains_key(&k2)
|
||||
|| map
|
||||
.keys()
|
||||
.any(|key| key.eq_ignore_ascii_case(&k1) || key.eq_ignore_ascii_case(&k2))
|
||||
}
|
||||
|
||||
pub fn remove_str(map: &mut HashMap<String, String>, suffix: &str) {
|
||||
let (k1, k2) = both_keys(suffix);
|
||||
map.remove(&k1);
|
||||
map.remove(&k2);
|
||||
map.retain(|key, _| !key.eq_ignore_ascii_case(&k1) && !key.eq_ignore_ascii_case(&k2));
|
||||
}
|
||||
|
||||
// === Vec<u8> type (meta_sys) ===
|
||||
@@ -178,4 +187,21 @@ mod tests {
|
||||
assert!(!has_internal_suffix("x-rustfs-internal-purgestatus", SUFFIX_HEALING));
|
||||
assert!(!has_internal_suffix("x-amz-meta-custom", SUFFIX_PURGESTATUS));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_str_lookup_accepts_minio_metadata_case() {
|
||||
let mut metadata = HashMap::from([
|
||||
("X-Minio-Internal-compression".to_string(), "klauspost/compress/s2".to_string()),
|
||||
("X-Minio-Internal-actual-size".to_string(), "268435456".to_string()),
|
||||
]);
|
||||
|
||||
assert!(contains_key_str(&metadata, SUFFIX_COMPRESSION));
|
||||
assert_eq!(get_str(&metadata, SUFFIX_COMPRESSION).as_deref(), Some("klauspost/compress/s2"));
|
||||
assert_eq!(get_str(&metadata, SUFFIX_ACTUAL_SIZE).as_deref(), Some("268435456"));
|
||||
|
||||
remove_str(&mut metadata, SUFFIX_COMPRESSION);
|
||||
assert!(!contains_key_str(&metadata, SUFFIX_COMPRESSION));
|
||||
assert!(!metadata.contains_key("X-Minio-Internal-compression"));
|
||||
assert!(contains_key_str(&metadata, SUFFIX_ACTUAL_SIZE));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user