mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-22 16:58:55 +00:00
Return EREMOTE when reading Glacier objects (#1705)
Previously s3fs returned EIO which was not helpful to the caller. Returning a more specific error code allows automatically restoring the object via RestoreObject in a subsequent commit. References #1466.
This commit is contained in:
parent
1965916f7a
commit
487df27008
@ -47,6 +47,7 @@ static const std::string empty_md5_base64_hash = "1B2M2Y8AsgTpgAmY7PhCfg=="
|
||||
// Class S3fsCurl
|
||||
//-------------------------------------------------------------------
|
||||
static const int MULTIPART_SIZE = 10 * 1024 * 1024;
|
||||
static const int GET_OBJECT_RESPONSE_LIMIT = 1024;
|
||||
|
||||
static const int IAM_EXPIRE_MERGIN = 20 * 60; // update timing
|
||||
static const std::string ECS_IAM_ENV_VAR = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
||||
@ -681,6 +682,11 @@ size_t S3fsCurl::DownloadWriteCallback(void* ptr, size_t size, size_t nmemb, voi
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Buffer initial bytes in case it is an XML error response.
|
||||
if(pCurl->bodydata.size() < GET_OBJECT_RESPONSE_LIMIT){
|
||||
pCurl->bodydata.Append(ptr, std::min(size * nmemb, GET_OBJECT_RESPONSE_LIMIT - pCurl->bodydata.size()));
|
||||
}
|
||||
|
||||
// write size
|
||||
ssize_t copysize = (size * nmemb) < (size_t)pCurl->partdata.size ? (size * nmemb) : (size_t)pCurl->partdata.size;
|
||||
ssize_t writebytes;
|
||||
@ -2320,6 +2326,9 @@ int S3fsCurl::RequestPerform(bool dontAddAuthHeaders /*=false*/)
|
||||
if(value == "EntityTooLarge"){
|
||||
result = -EFBIG;
|
||||
break;
|
||||
}else if(value == "InvalidObjectState"){
|
||||
result = -EREMOTE;
|
||||
break;
|
||||
}else if(value == "KeyTooLongError"){
|
||||
result = -ENAMETOOLONG;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user