rgw: fix radosgw-admin buckets list

Fixes: #5455
Backport: cuttlefish
This commit fixes a regression, where radosgw-admin buckets list
operation wasn't returning any data.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Yehuda Sadeh 2013-06-26 11:28:57 -07:00 committed by Sage Weil
parent fe6633172e
commit e1f9fe58d2
2 changed files with 13 additions and 7 deletions

View File

@ -863,11 +863,16 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher)
{
RGWBucket bucket;
int ret = bucket.init(store, op_state);
if (ret < 0)
return ret;
int ret;
string bucket_name = op_state.get_bucket_name();
if (!bucket_name.empty()) {
ret = bucket.init(store, op_state);
if (ret < 0)
return ret;
}
Formatter *formatter = flusher.get_formatter();
flusher.start(0);
@ -911,7 +916,8 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state,
} else {
RGWAccessHandle handle;
if (store->list_buckets_init(&handle) > 0) {
formatter->open_array_section("buckets");
if (store->list_buckets_init(&handle) >= 0) {
RGWObjEnt obj;
while (store->list_buckets_next(obj, &handle) >= 0) {
formatter->dump_string("bucket", obj.name);
@ -919,6 +925,8 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state,
bucket_stats(store, obj.name, formatter);
}
}
formatter->close_section();
}
flusher.flush();

View File

@ -428,9 +428,7 @@ int RGWRados::list_buckets_next(RGWObjEnt& obj, RGWAccessHandle *handle)
obj.name = (*state)->first;
(*state)++;
} while (obj.name[0] == '.');
/* FIXME: should read mtime/size vals for bucket */
} while (obj.name[0] == '.'); /* skip all entries starting with '.' */
return 0;
}