* and if mtime is >= it fails.
* if_match/nomatch: if non-NULL, compares the object's etag attr
* to the string and, if it doesn't/does match, fails out.
- * get_data: if true, the object's data/value will be read out, otherwise not
* err: Many errors will result in this structure being filled
* with extra informatin on the error.
* Returns: -ERR# on failure, otherwise
const time_t *unmod_ptr,
const char *if_match,
const char *if_nomatch,
- bool get_data,
+ size_t *total_size,
void **handle,
struct rgw_err *err) = 0;
char *data;
void *handle;
off_t ofs = 0, end = -1;
+ size_t total_len;
map<string, bufferlist> attrset;
ret = prepare_get_obj(src_bucket, src_obj, 0, &end, &attrset, mod_ptr, unmod_ptr,
- if_match, if_nomatch, true, &handle, err);
+ if_match, if_nomatch, &total_len, &handle, err);
if (ret < 0)
return ret;
const time_t *unmod_ptr,
const char *if_match,
const char *if_nomatch,
- bool get_data,
+ size_t *total_size,
void **handle,
struct rgw_err *err)
{
free(etag);
- if (!get_data) {
- r = max_len;
- goto done;
- }
-
+ *total_size = (max_len > 0 ? max_len : 0);
r = 0;
done:
return r;
const time_t *unmod_ptr,
const char *if_match,
const char *if_nomatch,
- bool get_data,
+ size_t *size,
void **handle,
struct rgw_err *err);
using namespace std;
-static int parse_range(const char *range, off_t ofs, off_t end)
+static int parse_range(const char *range, off_t& ofs, off_t& end)
{
int r = -ERANGE;
string s(range);
ofs_str = s.substr(0, pos);
end_str = s.substr(pos + 1);
- ofs = atoll(ofs_str.c_str());
+ if (ofs_str.length())
+ ofs = atoll(ofs_str.c_str());
+
+ if (end_str.length())
end = atoll(end_str.c_str());
+cout << "parse_range ofs=" << ofs << " end=" << end << std::endl;
+
if (end < ofs)
goto done;
goto done;
init_common();
-
- len = rgwstore->prepare_get_obj(s->bucket_str, s->object_str, ofs, &end, &attrs, mod_ptr,
- unmod_ptr, if_match, if_nomatch, get_data, &handle, &err);
-
- if (len < 0) {
- ret = len;
+cout << __func__ << ":" << __LINE__ << ": ofs=" << ofs << std::endl;
+ ret = rgwstore->prepare_get_obj(s->bucket_str, s->object_str, ofs, &end, &attrs, mod_ptr,
+ unmod_ptr, if_match, if_nomatch, &total_len, &handle, &err);
+ if (ret < 0)
goto done;
- }
- if (!get_data)
+cout << __func__ << ":" << __LINE__ << ": ofs=" << ofs << std::endl;
+
+ if (!get_data || ofs > end)
goto done;
while (ofs <= end) {
+cout << __func__ << ":" << __LINE__ << ": ofs=" << ofs << std::endl;
+
+cout << "RGWGetObj::execute():" << __LINE__ << ": len=" << len << std::endl;
len = rgwstore->get_obj(&handle, s->bucket_str, s->object_str, &data, ofs, end);
if (len < 0) {
ret = len;
goto done;
}
+cout << "RGWGetObj::execute():" << __LINE__ << ": len=" << len << std::endl;
+cout << __func__ << ":" << __LINE__ << ": ofs=" << ofs << std::endl;
ofs += len;
send_response(handle);
+cout << "RGWGetObj::execute():" << __LINE__ << ": len=" << len << std::endl;
free(data);
}
const char *if_match;
const char *if_nomatch;
off_t ofs;
- off_t len;
+ size_t len;
+ size_t total_len;
off_t end;
time_t mod_time;
time_t unmod_time;
RGWOp::init(s);
ofs = 0;
len = 0;
+ total_len = 0;
end = -1;
mod_ptr = NULL;
unmod_ptr = NULL;
+ data = NULL;
}
void set_get_data(bool get_data) {
this->get_data = get_data;
int ret, r;
char *data;
off_t ofs = 0, end = -1;
+ size_t total_len;
map<string, bufferlist>::iterator iter;
cerr << "copy " << src_bucket << ":" << src_obj << " => " << dest_bucket << ":" << dest_obj << std::endl;
map<string, bufferlist> attrset;
ret = prepare_get_obj(src_bucket, src_obj, ofs, &end, &attrset,
- mod_ptr, unmod_ptr, if_match, if_nomatch, true, &handle, err);
+ mod_ptr, unmod_ptr, if_match, if_nomatch, &total_len, &handle, err);
if (ret < 0)
return ret;
const time_t *unmod_ptr,
const char *if_match,
const char *if_nomatch,
- bool get_data,
+ size_t *total_size,
void **handle,
struct rgw_err *err)
{
if (*end < 0)
*end = size - 1;
- if (!get_data)
- return size;
+ *total_size = (ofs <= *end ? *end + 1 - ofs : 0);
return 0;
const time_t *unmod_ptr,
const char *if_match,
const char *if_nomatch,
- bool get_data,
+ size_t *total_size,
void **handle,
struct rgw_err *err);
goto send_data;
if (get_data && !ret) {
- dump_content_length(s, len);
+ dump_content_length(s, total_len);
}
if (!ret) {
map<string, bufferlist>::iterator iter = attrs.find(RGW_ATTR_ETAG);
struct rgw_err err;
void *handle;
off_t ofs = 0, end = -1;
+ size_t total_len;
bufferlist::iterator iter;
- ret = rgwstore->prepare_get_obj(ui_bucket, user_id, ofs, &end, NULL, NULL, NULL, NULL, NULL, true, &handle, &err);
+ ret = rgwstore->prepare_get_obj(ui_bucket, user_id, ofs, &end, NULL, NULL, NULL, NULL, NULL, &total_len, &handle, &err);
if (ret < 0)
return ret;
do {
void *handle;
off_t ofs = 0, end = -1;
bufferlist::iterator iter;
+ size_t total_len;
ret = rgwstore->prepare_get_obj(ui_email_bucket, email, ofs, &end, NULL, NULL,
- NULL, NULL, NULL, true, &handle, &err);
+ NULL, NULL, NULL, &total_len, &handle, &err);
if (ret < 0)
return ret;
do {