mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 01:08:54 +00:00
Improved processing when HEAD response is 400
This commit is contained in:
parent
493802a605
commit
4da56acdcc
@ -2310,8 +2310,13 @@ int S3fsCurl::RequestPerform(bool dontAddAuthHeaders /*=false*/)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 400:
|
case 400:
|
||||||
S3FS_PRN_ERR("HTTP response code %ld, returning EIO. Body Text: %s", responseCode, bodydata.str());
|
if(op == "HEAD"){
|
||||||
result = -EIO;
|
S3FS_PRN_ERR("HEAD HTTP response code %ld, returning EPERM. Body Text: %s", responseCode, bodydata.str());
|
||||||
|
result = -EPERM;
|
||||||
|
}else{
|
||||||
|
S3FS_PRN_ERR("HTTP response code %ld, returning EIO. Body Text: %s", responseCode, bodydata.str());
|
||||||
|
result = -EIO;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 403:
|
case 403:
|
||||||
|
27
src/s3fs.cpp
27
src/s3fs.cpp
@ -399,7 +399,26 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
|||||||
s3fscurl.DestroyCurlHandle();
|
s3fscurl.DestroyCurlHandle();
|
||||||
|
|
||||||
// if not found target path object, do over checking
|
// if not found target path object, do over checking
|
||||||
if(0 != result){
|
if(-EPERM == result){
|
||||||
|
// [NOTE]
|
||||||
|
// In case of a permission error, it exists in directory
|
||||||
|
// file list but inaccessible. So there is a problem that
|
||||||
|
// it will send a HEAD request every time, because it is
|
||||||
|
// not registered in the Stats cache.
|
||||||
|
// Therefore, even if the file has a permission error, it
|
||||||
|
// should be registered in the Stats cache. However, if
|
||||||
|
// the response without modifiying is registered in the
|
||||||
|
// cache, the file permission will be 0644(umask dependent)
|
||||||
|
// because the meta header does not exist.
|
||||||
|
// Thus, set the mode of 0000 here in the meta header so
|
||||||
|
// that s3fs can print a permission error when the file
|
||||||
|
// is actually accessed.
|
||||||
|
// It is better not to set meta header other than mode,
|
||||||
|
// so do not do it.
|
||||||
|
//
|
||||||
|
(*pheader)["x-amz-meta-mode"] = str(0);
|
||||||
|
|
||||||
|
}else if(0 != result){
|
||||||
if(overcheck){
|
if(overcheck){
|
||||||
// when support_compat_dir is disabled, strpath maybe have "_$folder$".
|
// when support_compat_dir is disabled, strpath maybe have "_$folder$".
|
||||||
if('/' != strpath[strpath.length() - 1] && std::string::npos == strpath.find("_$folder$", 0)){
|
if('/' != strpath[strpath.length() - 1] && std::string::npos == strpath.find("_$folder$", 0)){
|
||||||
@ -447,7 +466,11 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(0 != result){
|
// [NOTE]
|
||||||
|
// If the file is listed but not allowed access, put it in
|
||||||
|
// the positive cache instead of the negative cache.
|
||||||
|
//
|
||||||
|
if(0 != result && -EPERM != result){
|
||||||
// finally, "path" object did not find. Add no object cache.
|
// finally, "path" object did not find. Add no object cache.
|
||||||
strpath = path; // reset original
|
strpath = path; // reset original
|
||||||
StatCache::getStatCacheData()->AddNoObjectCache(strpath);
|
StatCache::getStatCacheData()->AddNoObjectCache(strpath);
|
||||||
|
Loading…
Reference in New Issue
Block a user