mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-22 16:58:55 +00:00
Simplify handling of returned ETag (#1479)
This works around lifetime warnings uncovered by cppcheck. References #1478.
This commit is contained in:
parent
834862f8a4
commit
f8d5b76edb
17
src/curl.cpp
17
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 += "<CompleteMultipartUpload>\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 += "<Part>\n";
|
||||
postContent += " <PartNumber>" + str(cnt + 1) + "</PartNumber>\n";
|
||||
postContent += " <ETag>" + parts[cnt] + "</ETag>\n";
|
||||
postContent += " <ETag>" + *it + "</ETag>\n";
|
||||
postContent += "</Part>\n";
|
||||
}
|
||||
postContent += "</CompleteMultipartUpload>\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();
|
||||
|
30
src/types.h
30
src/types.h
@ -243,22 +243,21 @@ enum signature_type_t {
|
||||
//----------------------------------------------
|
||||
// etaglist_t / filepart
|
||||
//----------------------------------------------
|
||||
typedef std::vector<std::string> etaglist_t;
|
||||
typedef std::list<std::string> 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();
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user