diff --git a/src/curl.cpp b/src/curl.cpp index fc9c3d3..4adea0c 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -1167,8 +1167,7 @@ S3fsCurl* S3fsCurl::UploadMultipartPostRetryCallback(S3fsCurl* s3fscurl) // duplicate request S3fsCurl* newcurl = new S3fsCurl(s3fscurl->IsUseAhbe()); - newcurl->partdata.etaglist = s3fscurl->partdata.etaglist; - newcurl->partdata.etagpos = s3fscurl->partdata.etagpos; + newcurl->partdata.petag = s3fscurl->partdata.petag; newcurl->partdata.fd = s3fscurl->partdata.fd; newcurl->partdata.startpos = s3fscurl->b_partdata_startpos; newcurl->partdata.size = s3fscurl->b_partdata_size; @@ -1215,8 +1214,7 @@ S3fsCurl* S3fsCurl::CopyMultipartPostRetryCallback(S3fsCurl* s3fscurl) // duplicate request S3fsCurl* newcurl = new S3fsCurl(s3fscurl->IsUseAhbe()); - newcurl->partdata.etaglist = s3fscurl->partdata.etaglist; - newcurl->partdata.etagpos = s3fscurl->partdata.etagpos; + newcurl->partdata.petag = s3fscurl->partdata.petag; newcurl->b_from = s3fscurl->b_from; newcurl->b_meta = s3fscurl->b_meta; newcurl->retry_count = s3fscurl->retry_count + 1; @@ -3499,14 +3497,15 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const std::string& // make contents std::string postContent; postContent += "\n"; - for(int cnt = 0; cnt < (int)parts.size(); cnt++){ - if(0 == parts[cnt].length()){ + int cnt = 0; + for(etaglist_t::iterator it = parts.begin(); it != parts.end(); ++it, ++cnt){ + if(it->empty()){ S3FS_PRN_ERR("%d file part is not finished uploading.", cnt + 1); return -1; } postContent += "\n"; postContent += " " + str(cnt + 1) + "\n"; - postContent += " " + parts[cnt] + "\n"; + postContent += " " + *it + "\n"; postContent += "\n"; } postContent += "\n"; @@ -3799,7 +3798,7 @@ bool S3fsCurl::UploadMultipartPostComplete() return false; } } - (*partdata.etaglist)[partdata.etagpos] = it->second; + (*partdata.petag) = it->second; partdata.uploaded = true; return true; @@ -3821,7 +3820,7 @@ bool S3fsCurl::CopyMultipartPostComplete() if(etag.size() >= 2 && *etag.begin() == '"' && *etag.rbegin() == '"'){ etag = etag.substr(1, etag.size() - 2); } - (*partdata.etaglist)[partdata.etagpos] = etag; + (*partdata.petag) = etag; bodydata.Clear(); headdata.Clear(); diff --git a/src/types.h b/src/types.h index 9aa96f2..ca4f2b4 100644 --- a/src/types.h +++ b/src/types.h @@ -243,22 +243,21 @@ enum signature_type_t { //---------------------------------------------- // etaglist_t / filepart //---------------------------------------------- -typedef std::vector etaglist_t; +typedef std::list etaglist_t; // // Each part information for Multipart upload // struct filepart { - bool uploaded; // does finish uploading - std::string etag; // expected etag value - int fd; // base file(temporary full file) descriptor - off_t startpos; // seek fd point for uploading - off_t size; // uploading size - etaglist_t* etaglist; // use only parallel upload - int etagpos; // use only parallel upload + bool uploaded; // does finish uploading + std::string etag; // expected etag value + int fd; // base file(temporary full file) descriptor + off_t startpos; // seek fd point for uploading + off_t size; // uploading size + std::string* petag; // use only parallel upload - filepart() : uploaded(false), fd(-1), startpos(0), size(-1), etaglist(NULL), etagpos(-1) {} + filepart() : uploaded(false), fd(-1), startpos(0), size(-1), petag(NULL) {} ~filepart() { clear(); @@ -271,20 +270,13 @@ struct filepart fd = -1; startpos = 0; size = -1; - etaglist = NULL; - etagpos = - 1; + petag = NULL; } void add_etag_list(etaglist_t* list) { - if(list){ - list->push_back(std::string("")); - etaglist = list; - etagpos = list->size() - 1; - }else{ - etaglist = NULL; - etagpos = - 1; - } + list->push_back(std::string()); + petag = &list->back(); } };