mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-01-08 23:54:14 +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
|
// duplicate request
|
||||||
S3fsCurl* newcurl = new S3fsCurl(s3fscurl->IsUseAhbe());
|
S3fsCurl* newcurl = new S3fsCurl(s3fscurl->IsUseAhbe());
|
||||||
newcurl->partdata.etaglist = s3fscurl->partdata.etaglist;
|
newcurl->partdata.petag = s3fscurl->partdata.petag;
|
||||||
newcurl->partdata.etagpos = s3fscurl->partdata.etagpos;
|
|
||||||
newcurl->partdata.fd = s3fscurl->partdata.fd;
|
newcurl->partdata.fd = s3fscurl->partdata.fd;
|
||||||
newcurl->partdata.startpos = s3fscurl->b_partdata_startpos;
|
newcurl->partdata.startpos = s3fscurl->b_partdata_startpos;
|
||||||
newcurl->partdata.size = s3fscurl->b_partdata_size;
|
newcurl->partdata.size = s3fscurl->b_partdata_size;
|
||||||
@ -1215,8 +1214,7 @@ S3fsCurl* S3fsCurl::CopyMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
|||||||
|
|
||||||
// duplicate request
|
// duplicate request
|
||||||
S3fsCurl* newcurl = new S3fsCurl(s3fscurl->IsUseAhbe());
|
S3fsCurl* newcurl = new S3fsCurl(s3fscurl->IsUseAhbe());
|
||||||
newcurl->partdata.etaglist = s3fscurl->partdata.etaglist;
|
newcurl->partdata.petag = s3fscurl->partdata.petag;
|
||||||
newcurl->partdata.etagpos = s3fscurl->partdata.etagpos;
|
|
||||||
newcurl->b_from = s3fscurl->b_from;
|
newcurl->b_from = s3fscurl->b_from;
|
||||||
newcurl->b_meta = s3fscurl->b_meta;
|
newcurl->b_meta = s3fscurl->b_meta;
|
||||||
newcurl->retry_count = s3fscurl->retry_count + 1;
|
newcurl->retry_count = s3fscurl->retry_count + 1;
|
||||||
@ -3499,14 +3497,15 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const std::string&
|
|||||||
// make contents
|
// make contents
|
||||||
std::string postContent;
|
std::string postContent;
|
||||||
postContent += "<CompleteMultipartUpload>\n";
|
postContent += "<CompleteMultipartUpload>\n";
|
||||||
for(int cnt = 0; cnt < (int)parts.size(); cnt++){
|
int cnt = 0;
|
||||||
if(0 == parts[cnt].length()){
|
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);
|
S3FS_PRN_ERR("%d file part is not finished uploading.", cnt + 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
postContent += "<Part>\n";
|
postContent += "<Part>\n";
|
||||||
postContent += " <PartNumber>" + str(cnt + 1) + "</PartNumber>\n";
|
postContent += " <PartNumber>" + str(cnt + 1) + "</PartNumber>\n";
|
||||||
postContent += " <ETag>" + parts[cnt] + "</ETag>\n";
|
postContent += " <ETag>" + *it + "</ETag>\n";
|
||||||
postContent += "</Part>\n";
|
postContent += "</Part>\n";
|
||||||
}
|
}
|
||||||
postContent += "</CompleteMultipartUpload>\n";
|
postContent += "</CompleteMultipartUpload>\n";
|
||||||
@ -3799,7 +3798,7 @@ bool S3fsCurl::UploadMultipartPostComplete()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(*partdata.etaglist)[partdata.etagpos] = it->second;
|
(*partdata.petag) = it->second;
|
||||||
partdata.uploaded = true;
|
partdata.uploaded = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -3821,7 +3820,7 @@ bool S3fsCurl::CopyMultipartPostComplete()
|
|||||||
if(etag.size() >= 2 && *etag.begin() == '"' && *etag.rbegin() == '"'){
|
if(etag.size() >= 2 && *etag.begin() == '"' && *etag.rbegin() == '"'){
|
||||||
etag = etag.substr(1, etag.size() - 2);
|
etag = etag.substr(1, etag.size() - 2);
|
||||||
}
|
}
|
||||||
(*partdata.etaglist)[partdata.etagpos] = etag;
|
(*partdata.petag) = etag;
|
||||||
|
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
headdata.Clear();
|
headdata.Clear();
|
||||||
|
30
src/types.h
30
src/types.h
@ -243,22 +243,21 @@ enum signature_type_t {
|
|||||||
//----------------------------------------------
|
//----------------------------------------------
|
||||||
// etaglist_t / filepart
|
// etaglist_t / filepart
|
||||||
//----------------------------------------------
|
//----------------------------------------------
|
||||||
typedef std::vector<std::string> etaglist_t;
|
typedef std::list<std::string> etaglist_t;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Each part information for Multipart upload
|
// Each part information for Multipart upload
|
||||||
//
|
//
|
||||||
struct filepart
|
struct filepart
|
||||||
{
|
{
|
||||||
bool uploaded; // does finish uploading
|
bool uploaded; // does finish uploading
|
||||||
std::string etag; // expected etag value
|
std::string etag; // expected etag value
|
||||||
int fd; // base file(temporary full file) descriptor
|
int fd; // base file(temporary full file) descriptor
|
||||||
off_t startpos; // seek fd point for uploading
|
off_t startpos; // seek fd point for uploading
|
||||||
off_t size; // uploading size
|
off_t size; // uploading size
|
||||||
etaglist_t* etaglist; // use only parallel upload
|
std::string* petag; // use only parallel upload
|
||||||
int etagpos; // 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()
|
~filepart()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
@ -271,20 +270,13 @@ struct filepart
|
|||||||
fd = -1;
|
fd = -1;
|
||||||
startpos = 0;
|
startpos = 0;
|
||||||
size = -1;
|
size = -1;
|
||||||
etaglist = NULL;
|
petag = NULL;
|
||||||
etagpos = - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_etag_list(etaglist_t* list)
|
void add_etag_list(etaglist_t* list)
|
||||||
{
|
{
|
||||||
if(list){
|
list->push_back(std::string());
|
||||||
list->push_back(std::string(""));
|
petag = &list->back();
|
||||||
etaglist = list;
|
|
||||||
etagpos = list->size() - 1;
|
|
||||||
}else{
|
|
||||||
etaglist = NULL;
|
|
||||||
etagpos = - 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user