1 /* 2 * Copyright 2009-2017 Alibaba Cloud All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 #include "ResumableBaseWorker.h" 19 20 namespace AlibabaCloud 21 { 22 namespace OSS 23 { 24 struct MultiCopyRecord { 25 std::string opType; 26 std::string uploadID; 27 std::string srcBucket; 28 std::string srcKey; 29 std::string bucket; 30 std::string key; 31 std::string mtime; 32 uint64_t size; 33 uint64_t partSize; 34 std::string md5Sum; 35 }; 36 37 class ResumableCopier : public ResumableBaseWorker 38 { 39 public: ResumableCopier(const MultiCopyObjectRequest & request,const OssClientImpl * client,uint64_t objectSize)40 ResumableCopier(const MultiCopyObjectRequest &request, const OssClientImpl *client, uint64_t objectSize) 41 :ResumableBaseWorker(objectSize, request.PartSize()), request_(request), client_(client) 42 { 43 } 44 CopyObjectOutcome Copy(); 45 46 protected: 47 void genRecordPath(); 48 int loadRecord(); 49 int validateRecord(); 50 int prepare(OssError& err); 51 void initRecord(const std::string &uploadID); 52 int getPartsToUploadCopy(OssError &err, PartList &partsCopied, PartList &partsToUpload); 53 54 const MultiCopyObjectRequest request_; 55 MultiCopyRecord record_; 56 const OssClientImpl *client_; 57 std::string uploadID_; 58 }; 59 } 60 } 61