mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-19 11:06:17 +00:00
fix: correct max_keys field in list_object_versions response (#1576)
Signed-off-by: 安正超 <anzhengchao@gmail.com> Co-authored-by: loverustfs <hello@rustfs.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -34,3 +34,6 @@ artifacts/
|
|||||||
*.events
|
*.events
|
||||||
*.audit
|
*.audit
|
||||||
*.snappy
|
*.snappy
|
||||||
|
PR_DESCRIPTION.md
|
||||||
|
IMPLEMENTATION_PLAN.md
|
||||||
|
scripts/s3-tests/selected_tests.txt
|
||||||
|
|||||||
@@ -428,6 +428,13 @@ impl ECStore {
|
|||||||
result.forward_past(opts.marker);
|
result.forward_past(opts.marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if list_path returned entries equal to limit, which indicates more objects exist
|
||||||
|
// This is more accurate than checking get_objects.len() because get_objects may be filtered
|
||||||
|
// (e.g., directories filtered out), so its length may be less than the actual entries count
|
||||||
|
// We need to check this before calling from_meta_cache_entries_sorted_versions which consumes entries
|
||||||
|
let entries_count = list_result.entries.as_ref().map(|e| e.entries().len()).unwrap_or(0);
|
||||||
|
let limit = opts.limit;
|
||||||
|
|
||||||
let mut get_objects = ObjectInfo::from_meta_cache_entries_sorted_versions(
|
let mut get_objects = ObjectInfo::from_meta_cache_entries_sorted_versions(
|
||||||
&list_result.entries.unwrap_or_default(),
|
&list_result.entries.unwrap_or_default(),
|
||||||
bucket,
|
bucket,
|
||||||
@@ -441,7 +448,11 @@ impl ECStore {
|
|||||||
if max_keys > 0 && get_objects.len() > max_keys as usize {
|
if max_keys > 0 && get_objects.len() > max_keys as usize {
|
||||||
get_objects.truncate(max_keys as usize);
|
get_objects.truncate(max_keys as usize);
|
||||||
true
|
true
|
||||||
|
} else if entries_count >= limit as usize {
|
||||||
|
// If entries count equals limit, there are more objects
|
||||||
|
true
|
||||||
} else {
|
} else {
|
||||||
|
// Otherwise, check if there are any objects and no error
|
||||||
list_result.err.is_none() && !get_objects.is_empty()
|
list_result.err.is_none() && !get_objects.is_empty()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3725,8 +3725,6 @@ impl S3 for FS {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let key_count = objects.len() as i32;
|
|
||||||
|
|
||||||
let common_prefixes = object_infos
|
let common_prefixes = object_infos
|
||||||
.prefixes
|
.prefixes
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -3753,7 +3751,9 @@ impl S3 for FS {
|
|||||||
|
|
||||||
let output = ListObjectVersionsOutput {
|
let output = ListObjectVersionsOutput {
|
||||||
is_truncated: Some(object_infos.is_truncated),
|
is_truncated: Some(object_infos.is_truncated),
|
||||||
max_keys: Some(key_count),
|
// max_keys should be the requested maximum number of keys, not the actual count returned
|
||||||
|
// Per AWS S3 API spec, this field represents the maximum number of keys that can be returned in the response
|
||||||
|
max_keys: Some(max_keys),
|
||||||
delimiter,
|
delimiter,
|
||||||
name: Some(bucket),
|
name: Some(bucket),
|
||||||
prefix: Some(prefix),
|
prefix: Some(prefix),
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
# - Metadata: User-defined metadata
|
# - Metadata: User-defined metadata
|
||||||
# - Conditional GET: If-Match, If-None-Match, If-Modified-Since
|
# - Conditional GET: If-Match, If-None-Match, If-Modified-Since
|
||||||
#
|
#
|
||||||
# Total: 118 tests
|
# Total: 119 tests
|
||||||
|
|
||||||
test_basic_key_count
|
test_basic_key_count
|
||||||
test_bucket_create_naming_bad_short_one
|
test_bucket_create_naming_bad_short_one
|
||||||
@@ -63,6 +63,7 @@ test_bucket_list_prefix_none
|
|||||||
test_bucket_list_prefix_not_exist
|
test_bucket_list_prefix_not_exist
|
||||||
test_bucket_list_prefix_unreadable
|
test_bucket_list_prefix_unreadable
|
||||||
test_bucket_list_special_prefix
|
test_bucket_list_special_prefix
|
||||||
|
test_bucket_list_delimiter_basic
|
||||||
test_bucket_list_delimiter_alt
|
test_bucket_list_delimiter_alt
|
||||||
test_bucket_list_delimiter_dot
|
test_bucket_list_delimiter_dot
|
||||||
test_bucket_list_delimiter_empty
|
test_bucket_list_delimiter_empty
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ test_versioning_obj_suspend_versions
|
|||||||
|
|
||||||
# Teardown issues (list_object_versions on non-versioned buckets)
|
# Teardown issues (list_object_versions on non-versioned buckets)
|
||||||
# These tests pass but have cleanup issues with list_object_versions
|
# These tests pass but have cleanup issues with list_object_versions
|
||||||
test_bucket_list_delimiter_basic
|
|
||||||
test_bucket_list_encoding_basic
|
test_bucket_list_encoding_basic
|
||||||
test_bucket_listv2_delimiter_alt
|
test_bucket_listv2_delimiter_alt
|
||||||
test_bucket_listv2_delimiter_basic
|
test_bucket_listv2_delimiter_basic
|
||||||
|
|||||||
Reference in New Issue
Block a user