Skip to content

Commit

Permalink
Merge pull request #12258: jewel: rgw: add support for the prefix par…
Browse files Browse the repository at this point in the history
…ameter in account listing of Swift API

Reviewed-by: Loic Dachary <ldachary@redhat.com>
  • Loading branch information
Loic Dachary committed Dec 5, 2016
2 parents fdc9b05 + d9c1d86 commit 174835d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/rgw/rgw_rest_swift.cc
Expand Up @@ -23,6 +23,7 @@

int RGWListBuckets_ObjStore_SWIFT::get_params()
{
prefix = s->info.args.get("prefix");
marker = s->info.args.get("marker");
end_marker = s->info.args.get("end_marker");

Expand Down Expand Up @@ -144,22 +145,28 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_begin(bool has_buckets)

void RGWListBuckets_ObjStore_SWIFT::send_response_data(RGWUserBuckets& buckets)
{
map<string, RGWBucketEnt>& m = buckets.get_buckets();
map<string, RGWBucketEnt>::iterator iter;

if (!sent_data)
if (! sent_data) {
return;
}

/* Take care of the prefix parameter of Swift API. There is no business
* in applying the filter earlier as we really need to go through all
* entries regardless of it (the headers like X-Account-Container-Count
* aren't affected by specifying prefix). */
const std::map<std::string, RGWBucketEnt>& m = buckets.get_buckets();
for (auto iter = m.lower_bound(prefix);
iter != m.end() && boost::algorithm::starts_with(iter->first, prefix);
++iter) {
const RGWBucketEnt& obj = iter->second;

for (iter = m.begin(); iter != m.end(); ++iter) {
RGWBucketEnt obj = iter->second;
s->formatter->open_object_section("container");
s->formatter->dump_string("name", obj.bucket.name);
if (need_stats) {
s->formatter->dump_int("count", obj.count);
s->formatter->dump_int("bytes", obj.size);
}
s->formatter->close_section();
if (!g_conf->rgw_swift_enforce_content_length) {
if (! g_conf->rgw_swift_enforce_content_length) {
rgw_flush_formatter(s, s->formatter);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_rest_swift.h
Expand Up @@ -21,6 +21,7 @@ class RGWGetObj_ObjStore_SWIFT : public RGWGetObj_ObjStore {

class RGWListBuckets_ObjStore_SWIFT : public RGWListBuckets_ObjStore {
bool need_stats;
std::string prefix;

uint64_t get_default_max() const override {
return 0;
Expand Down

0 comments on commit 174835d

Please sign in to comment.