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:
LeonWang0735
2026-01-27 16:56:31 +08:00
committed by GitHub
parent 74759b6e99
commit 8edb1affc0
4 changed files with 19 additions and 14 deletions
+10 -3
View File
@@ -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;
}