From fdd98eeb22488b1d417d5653542133fc2d36fc6c Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 20 Sep 2011 14:21:13 -0700 Subject: [PATCH] rgw: fix bucket listing (still using old scheme) --- src/rgw/rgw_rados.cc | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index c6582a542ebcf..09ce3a42cc3a4 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -36,18 +36,23 @@ public: } }; -static void get_obj_bucket_and_oid(rgw_obj& obj, rgw_bucket& bucket, string& oid) +static void prepend_bucket_marker(rgw_bucket& bucket, string& orig_oid, string& oid) { - bucket = obj.bucket; - if (bucket.marker.empty() || obj.object.empty()) { - oid = obj.object; + if (bucket.marker.empty() || orig_oid.empty()) { + oid = orig_oid; } else { oid = bucket.marker; oid.append("_"); - oid.append(obj.object); + oid.append(orig_oid); } } +static void get_obj_bucket_and_oid(rgw_obj& obj, rgw_bucket& bucket, string& oid) +{ + bucket = obj.bucket; + prepend_bucket_marker(bucket, obj.object, oid); +} + /** * Initialize the RADOS instance and prepare to do other ops @@ -229,9 +234,14 @@ int RGWRados::list_objects(string& id, rgw_bucket& bucket, int max, string& pref string obj = *i; string key = obj; - if (bucket_marker.size() && obj.compare(0, bucket_marker.size(), bucket_marker) != 0) + if (bucket_marker.size()) { + if (obj.compare(0, bucket_marker.size(), bucket_marker) != 0) continue; + obj = obj.substr(bucket_marker.size()); + key = obj; + } + if (!rgw_obj::translate_raw_obj(obj, ns)) continue; @@ -279,10 +289,13 @@ int RGWRados::list_objects(string& id, rgw_bucket& bucket, int max, string& pref oid.append(name); } + string new_oid; + prepend_bucket_marker(bucket, oid, new_oid); + uint64_t s; - if (key.compare(name) != 0) - io_ctx.locator_set_key(key); - if (io_ctx.stat(oid, &s, &obj.mtime) < 0) + io_ctx.locator_set_key(key); + + if (io_ctx.stat(new_oid, &s, &obj.mtime) < 0) continue; obj.size = s; -- 2.39.5