From a1afbc770cf73ce7f99f8a5d3ad935d12a908bcb Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Thu, 24 Sep 2020 23:34:43 +0800 Subject: [PATCH] rgw: fix: S3 API KeyCount incorrect return. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit KeyCount should return object count + common prefix count. see S3 example: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html#API_ListObjectsV2_Example_5 Related: https://github.com/docker/distribution/issues/3200 Signed-off-by: 胡玮文 (cherry picked from commit f96a6fdad16da2a7093f538ee577248dfbc65ca1) --- src/rgw/rgw_rest_s3.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 9070f86e2d595..703fff8d98111 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -1139,7 +1139,7 @@ void RGWListBucket_ObjStore_S3v2::send_response() if (is_truncated && !next_marker.empty()) { s->formatter->dump_string("NextContinuationToken", next_marker.name); } - s->formatter->dump_int("KeyCount",objs.size()); + s->formatter->dump_int("KeyCount", objs.size() + common_prefixes.size()); if (start_after_exist) { s->formatter->dump_string("StartAfter", startAfter); } -- 2.39.5