mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 01:08:54 +00:00
Merge pull request #1 from ggtakec/test
Refactored the get_object_attribute function
This commit is contained in:
commit
67685c3d49
84
src/s3fs.cpp
84
src/s3fs.cpp
@ -421,14 +421,13 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
||||
}
|
||||
|
||||
// Check cache.
|
||||
strpath = path;
|
||||
pisforce = (NULL != pisforce ? pisforce : &forcedir);
|
||||
(*pisforce) = false;
|
||||
strpath = path;
|
||||
if(overcheck && string::npos != (Pos = strpath.find("_$folder$", 0))){
|
||||
strpath = strpath.substr(0, Pos);
|
||||
strpath += "/";
|
||||
}
|
||||
if(pisforce){
|
||||
(*pisforce) = false;
|
||||
}
|
||||
if(StatCache::getStatCacheData()->GetStat(strpath, pstat, pheader, overcheck, pisforce)){
|
||||
StatCache::getStatCacheData()->ChangeNoTruncateFlag(strpath, add_no_truncate_cache);
|
||||
return 0;
|
||||
@ -443,57 +442,50 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
||||
result = s3fscurl.HeadRequest(strpath.c_str(), (*pheader));
|
||||
s3fscurl.DestroyCurlHandle();
|
||||
|
||||
// overcheck
|
||||
if(overcheck && 0 != result){
|
||||
if('/' != strpath[strpath.length() - 1] && string::npos == strpath.find("_$folder$", 0)){
|
||||
// path is "object", check "object/" for overcheck
|
||||
strpath += "/";
|
||||
result = s3fscurl.HeadRequest(strpath.c_str(), (*pheader));
|
||||
s3fscurl.DestroyCurlHandle();
|
||||
}
|
||||
if(0 != result){
|
||||
// not found "object/", check "_$folder$"
|
||||
strpath = path;
|
||||
if(string::npos == strpath.find("_$folder$", 0)){
|
||||
if('/' == strpath[strpath.length() - 1]){
|
||||
strpath = strpath.substr(0, strpath.length() - 1);
|
||||
}
|
||||
strpath += "_$folder$";
|
||||
// if not found target path object, do over checking
|
||||
if(0 != result){
|
||||
if(overcheck){
|
||||
if('/' != strpath[strpath.length() - 1]){
|
||||
// now path is "object", do check "object/" for over checking
|
||||
strpath += "/";
|
||||
result = s3fscurl.HeadRequest(strpath.c_str(), (*pheader));
|
||||
s3fscurl.DestroyCurlHandle();
|
||||
}
|
||||
}
|
||||
if(0 != result){
|
||||
// not found "object/" and "object_$folder$", check no dir object.
|
||||
strpath = path;
|
||||
if(string::npos == strpath.find("_$folder$", 0)){
|
||||
if('/' == strpath[strpath.length() - 1]){
|
||||
strpath = strpath.substr(0, strpath.length() - 1);
|
||||
}
|
||||
if(-ENOTEMPTY == directory_empty(strpath.c_str())){
|
||||
// found "no dir object".
|
||||
strpath += "/";
|
||||
forcedir = true;
|
||||
if(pisforce){
|
||||
(*pisforce) = true;
|
||||
if(0 != result){
|
||||
// now path is "object/", do check "object_$folder$" for over checking
|
||||
strpath = strpath.substr(0, strpath.length() - 1);
|
||||
strpath += "_$folder$";
|
||||
result = s3fscurl.HeadRequest(strpath.c_str(), (*pheader));
|
||||
s3fscurl.DestroyCurlHandle();
|
||||
|
||||
if(0 != result){
|
||||
// cut "_$folder$" for over checking "no dir object" after here
|
||||
if(string::npos != (Pos = strpath.find("_$folder$", 0))){
|
||||
strpath = strpath.substr(0, Pos);
|
||||
}
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(0 != result && string::npos == strpath.find("_$folder$", 0)){
|
||||
// now path is "object" or "object/", do check "no dir object" which is not object but has only children.
|
||||
if('/' == strpath[strpath.length() - 1]){
|
||||
strpath = strpath.substr(0, strpath.length() - 1);
|
||||
}
|
||||
if(-ENOTEMPTY == directory_empty(strpath.c_str())){
|
||||
// found "no dir object".
|
||||
strpath += "/";
|
||||
*pisforce = true;
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// found "path" object.
|
||||
if('/' != strpath[strpath.length() - 1]){
|
||||
if('/' != strpath[strpath.length() - 1] && string::npos == strpath.find("_$folder$", 0) && is_need_check_obj_detail(*pheader)){
|
||||
// check a case of that "object" does not have attribute and "object" is possible to be directory.
|
||||
if(is_need_check_obj_detail(*pheader)){
|
||||
if(-ENOTEMPTY == directory_empty(strpath.c_str())){
|
||||
strpath += "/";
|
||||
forcedir = true;
|
||||
if(pisforce){
|
||||
(*pisforce) = true;
|
||||
}
|
||||
result = 0;
|
||||
}
|
||||
if(-ENOTEMPTY == directory_empty(strpath.c_str())){
|
||||
// found "no dir object".
|
||||
strpath += "/";
|
||||
*pisforce = true;
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user