if (! f->write_req) {
/* start */
- std::string object_name = full_object_name();
+ std::string object_name = relative_object_name();
f->write_req =
new RGWWriteRequest(fs->get_context(), fs->get_user(), this,
bucket_name(), object_name);
buffer::list bl;
fhr = fs->lookup_fh(parent, name, RGWFileHandle::FLAG_PSEUDO);
rgw_fh = get<0>(fhr);
- string dir_name = rgw_fh->full_object_name() + "/";
+ string dir_name = rgw_fh->relative_object_name() + "/";
RGWPutObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
dir_name, bl);
rc = librgw.get_fe()->execute_req(&req);
if (! rc) {
/* rgw_fh ref+ */
RGWFileHandle* rgw_fh = get_rgwfh(fh);
- std::string oname = rgw_fh->full_object_name();
+ std::string oname = rgw_fh->relative_object_name();
RGWDeleteObjRequest req(cct, fs->get_user(), parent->bucket_name(),
oname);
rc = librgw.get_fe()->execute_req(&req);
static_cast<char*>(vio->vio_base)));
}
- std::string oname = rgw_fh->full_object_name();
+ std::string oname = rgw_fh->relative_object_name();
RGWPutObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
oname, bl);
const std::string& object_name() const { return name; }
- std::string full_object_name(uint8_t min_depth = 1) {
- if (depth <= min_depth) {
+ std::string full_object_name(bool omit_bucket = false) {
+ if (depth <= 1) {
return "";
}
std::string path;
std::vector<const std::string*> segments;
int reserve = 0;
RGWFileHandle* tfh = this;
- while (tfh && !tfh->is_bucket()) {
+ while (tfh && !tfh->is_root() && !(tfh->is_bucket() && omit_bucket)) {
segments.push_back(&tfh->object_name());
reserve += (1 + tfh->object_name().length());
tfh = tfh->parent;
for (auto& s : boost::adaptors::reverse(segments)) {
if (! first)
path += "/";
- else
+ else {
+ if (!omit_bucket && (path.front() != '/')) // pretty-print
+ path += "/";
first = false;
+ }
path += *s;
}
return path;
}
+ inline std::string relative_object_name() {
+ return full_object_name(false /* omit_bucket */);
+ }
+
+
+ inline std::string search_prefix() {
+ return full_object_name(true /* omit_bucket */);
+ }
+
inline std::string make_key_name(const char *name) {
std::string key_name{full_object_name()};
if (key_name.length() > 0)
// woo
s->user = user;
- prefix = rgw_fh->full_object_name();
+ prefix = rgw_fh->search_prefix();
if (prefix.length() > 0)
prefix += "/";
delimiter = '/';
// woo
s->user = user;
- prefix = rgw_fh->full_object_name();
+ prefix = rgw_fh->search_prefix();
if (prefix.length() > 0)
prefix += "/";
prefix += path;