]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: If use 'copy part' without 'x-amz-copy-source-range',
authorMalcolm Lee <fengxueyu35@126.com>
Wed, 31 Jan 2018 02:45:19 +0000 (10:45 +0800)
committerMalcolm Lee <fengxueyu35@126.com>
Wed, 31 Jan 2018 05:56:02 +0000 (13:56 +0800)
it will copy an entire source object

Signed-off-by: Malcolm Lee <fengxueyu35@126.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rest_s3.cc

index c9617d4fbd5f16333a3d608005068c3845f3066a..dc9af6d640c702ed5f11a3bf5b7d30ed022c3c8b 100644 (file)
@@ -3378,8 +3378,27 @@ void RGWPutObj::execute()
     goto done;
   }
 
+  if ((! copy_source.empty()) && !copy_source_range) {
+    rgw_obj_key obj_key(copy_source_object_name, copy_source_version_id);
+    rgw_obj obj(copy_source_bucket_info.bucket, obj_key.name);
+
+    RGWObjState *astate;
+    op_ret = store->get_obj_state(static_cast<RGWObjectCtx *>(s->obj_ctx),
+                                  copy_source_bucket_info, obj, &astate, true, false);
+    if (op_ret < 0) {
+      ldout(s->cct, 0) << "ERROR: get copy source obj state returned with error" << op_ret << dendl;
+      goto done;
+    }
+    if (!astate->exists){
+      op_ret = -ENOENT;
+      goto done;
+    }
+    lst = astate->size - 1;
+  } else {
+    lst = copy_source_range_lst;
+  }
+
   fst = copy_source_range_fst;
-  lst = copy_source_range_lst;
 
   op_ret = get_encrypt_filter(&encrypt, filter);
   if (op_ret < 0) {
index ec774deb3b9add3ccbb4b4ee97216c424ce34b66..bd63930c5dbbd3cf56c63cca2c3f64a6b558b874 100644 (file)
@@ -3279,10 +3279,12 @@ int RGWHandler_REST_S3::init(RGWRados *store, struct req_state *s,
 
   const char *copy_source = s->info.env->get("HTTP_X_AMZ_COPY_SOURCE");
   if (copy_source &&
-      (! s->info.env->get("HTTP_X_AMZ_COPY_SOURCE_RANGE"))) {
-       ret = RGWCopyObj::parse_copy_location(url_decode(copy_source),
-                                           s->init_state.src_bucket,
-                                           s->src_object);
+      (! s->info.env->get("HTTP_X_AMZ_COPY_SOURCE_RANGE")) &&
+      (! s->info.args.exists("uploadId"))) {
+
+    ret = RGWCopyObj::parse_copy_location(url_decode(copy_source),
+                                          s->init_state.src_bucket,
+                                          s->src_object);
     if (!ret) {
       ldout(s->cct, 0) << "failed to parse copy location" << dendl;
       return -EINVAL; // XXX why not -ERR_INVALID_BUCKET_NAME or -ERR_BAD_URL?