mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-11 07:36:53 +00:00
Fix:s3 compatibility (#1617)
Co-authored-by: houseme <housemecn@gmail.com> Co-authored-by: loverustfs <hello@rustfs.com> Co-authored-by: heihutu <30542132+heihutu@users.noreply.github.com>
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
use s3s::dto::Tag;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
use url::form_urlencoded;
|
||||
|
||||
@@ -22,7 +23,7 @@ pub fn decode_tags(tags: &str) -> Vec<Tag> {
|
||||
let mut list = Vec::new();
|
||||
|
||||
for (k, v) in values {
|
||||
if k.is_empty() || v.is_empty() {
|
||||
if k.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -31,7 +32,13 @@ pub fn decode_tags(tags: &str) -> Vec<Tag> {
|
||||
value: Some(v.to_string()),
|
||||
});
|
||||
}
|
||||
|
||||
// use pattern matching instead of unwrap(), no panic even if the key becomes None later
|
||||
list.sort_by(|a, b| match (a.key.as_ref(), b.key.as_ref()) {
|
||||
(Some(a_k), Some(b_k)) => a_k.cmp(b_k),
|
||||
(Some(_), None) => Ordering::Greater,
|
||||
(None, Some(_)) => Ordering::Less,
|
||||
(None, None) => Ordering::Equal,
|
||||
});
|
||||
list
|
||||
}
|
||||
|
||||
@@ -39,7 +46,7 @@ pub fn decode_tags_to_map(tags: &str) -> HashMap<String, String> {
|
||||
let mut list = HashMap::new();
|
||||
|
||||
for (k, v) in form_urlencoded::parse(tags.as_bytes()) {
|
||||
if k.is_empty() || v.is_empty() {
|
||||
if k.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user