mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 17:28:56 +00:00
fix multipart upload handling without cache
This commit is contained in:
parent
43df94719b
commit
8ee95ff7ab
44
src/curl.cpp
44
src/curl.cpp
@ -1148,18 +1148,8 @@ bool S3fsCurl::UploadMultipartPostCallback(S3fsCurl* s3fscurl)
|
|||||||
if(!s3fscurl){
|
if(!s3fscurl){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
headers_t::iterator it = s3fscurl->responseHeaders.find("ETag");
|
|
||||||
if (it == s3fscurl->responseHeaders.end()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// check etag(md5);
|
|
||||||
if(S3fsCurl::is_content_md5 && !etag_equals(it->second, s3fscurl->partdata.etag)){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
s3fscurl->partdata.etaglist->at(s3fscurl->partdata.etagpos).assign(it->second);
|
|
||||||
s3fscurl->partdata.uploaded = true;
|
|
||||||
|
|
||||||
return true;
|
return s3fscurl->UploadMultipartPostComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
S3fsCurl* S3fsCurl::UploadMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
S3fsCurl* S3fsCurl::UploadMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
||||||
@ -3431,12 +3421,8 @@ int S3fsCurl::UploadMultipartPostRequest(const char* tpath, int part_num, const
|
|||||||
|
|
||||||
// request
|
// request
|
||||||
if(0 == (result = RequestPerform())){
|
if(0 == (result = RequestPerform())){
|
||||||
// check etag
|
// UploadMultipartPostComplete returns true on success -> convert to 0
|
||||||
if(NULL != strstr(headdata->str(), partdata.etag.c_str())){
|
result = !UploadMultipartPostComplete();
|
||||||
partdata.uploaded = true;
|
|
||||||
}else{
|
|
||||||
result = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// closing
|
// closing
|
||||||
@ -3557,6 +3543,22 @@ int S3fsCurl::CopyMultipartPostRequest(const char* from, const char* to, int par
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool S3fsCurl::UploadMultipartPostComplete()
|
||||||
|
{
|
||||||
|
headers_t::iterator it = responseHeaders.find("ETag");
|
||||||
|
if (it == responseHeaders.end()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// check etag(md5);
|
||||||
|
if(S3fsCurl::is_content_md5 && !etag_equals(it->second, partdata.etag)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
partdata.etaglist->at(partdata.etagpos).assign(it->second);
|
||||||
|
partdata.uploaded = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int S3fsCurl::MultipartHeadRequest(const char* tpath, off_t size, headers_t& meta, bool is_copy)
|
int S3fsCurl::MultipartHeadRequest(const char* tpath, off_t size, headers_t& meta, bool is_copy)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
@ -3637,14 +3639,14 @@ int S3fsCurl::MultipartUploadRequest(const char* tpath, headers_t& meta, int fd,
|
|||||||
partdata.size = chunk;
|
partdata.size = chunk;
|
||||||
b_partdata_startpos = partdata.startpos;
|
b_partdata_startpos = partdata.startpos;
|
||||||
b_partdata_size = partdata.size;
|
b_partdata_size = partdata.size;
|
||||||
|
partdata.add_etag_list(&list);
|
||||||
|
|
||||||
// upload part
|
// upload part
|
||||||
if(0 != (result = UploadMultipartPostRequest(tpath, (list.size() + 1), upload_id))){
|
if(0 != (result = UploadMultipartPostRequest(tpath, list.size(), upload_id))){
|
||||||
S3FS_PRN_ERR("failed uploading part(%d)", result);
|
S3FS_PRN_ERR("failed uploading part(%d)", result);
|
||||||
close(fd2);
|
close(fd2);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
list.push_back(partdata.etag);
|
|
||||||
DestroyCurlHandle();
|
DestroyCurlHandle();
|
||||||
}
|
}
|
||||||
close(fd2);
|
close(fd2);
|
||||||
@ -3675,15 +3677,15 @@ int S3fsCurl::MultipartUploadRequest(const string& upload_id, const char* tpath,
|
|||||||
partdata.size = size;
|
partdata.size = size;
|
||||||
b_partdata_startpos = partdata.startpos;
|
b_partdata_startpos = partdata.startpos;
|
||||||
b_partdata_size = partdata.size;
|
b_partdata_size = partdata.size;
|
||||||
|
partdata.add_etag_list(&list);
|
||||||
|
|
||||||
// upload part
|
// upload part
|
||||||
int result;
|
int result;
|
||||||
if(0 != (result = UploadMultipartPostRequest(tpath, (list.size() + 1), upload_id))){
|
if(0 != (result = UploadMultipartPostRequest(tpath, list.size(), upload_id))){
|
||||||
S3FS_PRN_ERR("failed uploading part(%d)", result);
|
S3FS_PRN_ERR("failed uploading part(%d)", result);
|
||||||
close(fd2);
|
close(fd2);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
list.push_back(partdata.etag);
|
|
||||||
DestroyCurlHandle();
|
DestroyCurlHandle();
|
||||||
close(fd2);
|
close(fd2);
|
||||||
|
|
||||||
|
@ -319,6 +319,7 @@ class S3fsCurl
|
|||||||
|
|
||||||
int UploadMultipartPostSetup(const char* tpath, int part_num, const std::string& upload_id);
|
int UploadMultipartPostSetup(const char* tpath, int part_num, const std::string& upload_id);
|
||||||
int CopyMultipartPostRequest(const char* from, const char* to, int part_num, std::string& upload_id, headers_t& meta);
|
int CopyMultipartPostRequest(const char* from, const char* to, int part_num, std::string& upload_id, headers_t& meta);
|
||||||
|
bool UploadMultipartPostComplete();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// class methods
|
// class methods
|
||||||
|
Loading…
Reference in New Issue
Block a user