diff --git a/ecstore/src/store_utils.rs b/ecstore/src/store_utils.rs new file mode 100644 index 000000000..358710c38 --- /dev/null +++ b/ecstore/src/store_utils.rs @@ -0,0 +1,21 @@ +use crate::config::storageclass::STANDARD; +use crate::xhttp::AMZ_OBJECT_TAGGING; +use crate::xhttp::AMZ_STORAGE_CLASS; +use std::collections::HashMap; + +pub fn clean_metadata(metadata: &mut HashMap) { + remove_standard_storage_class(metadata); + clean_metadata_keys(metadata, &["md5Sum", "etag", "expires", AMZ_OBJECT_TAGGING, "last-modified"]); +} + +pub fn remove_standard_storage_class(metadata: &mut HashMap) { + if metadata.get(AMZ_STORAGE_CLASS) == Some(&STANDARD.to_string()) { + metadata.remove(AMZ_STORAGE_CLASS); + } +} + +pub fn clean_metadata_keys(metadata: &mut HashMap, key_names: &[&str]) { + for key in key_names { + metadata.remove(key.to_owned()); + } +}