mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-11-18 02:05:13 +00:00
Merge pull request #101 from adobos/directory_empty_optimization
Optimized function "bool directory_empty()"
This commit is contained in:
commit
939ba2b4b3
15
src/s3fs.cpp
15
src/s3fs.cpp
@ -124,7 +124,7 @@ static FdEntity* get_local_fent(const char* path, bool is_load = false);
|
|||||||
static bool multi_head_callback(S3fsCurl* s3fscurl);
|
static bool multi_head_callback(S3fsCurl* s3fscurl);
|
||||||
static S3fsCurl* multi_head_retry_callback(S3fsCurl* s3fscurl);
|
static S3fsCurl* multi_head_retry_callback(S3fsCurl* s3fscurl);
|
||||||
static int readdir_multi_head(const char* path, S3ObjList& head, void* buf, fuse_fill_dir_t filler);
|
static int readdir_multi_head(const char* path, S3ObjList& head, void* buf, fuse_fill_dir_t filler);
|
||||||
static int list_bucket(const char* path, S3ObjList& head, const char* delimiter);
|
static int list_bucket(const char* path, S3ObjList& head, const char* delimiter, bool check_content_only = false);
|
||||||
static int directory_empty(const char* path);
|
static int directory_empty(const char* path);
|
||||||
static bool is_truncated(xmlDocPtr doc);;
|
static bool is_truncated(xmlDocPtr doc);;
|
||||||
static int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathContextPtr ctx,
|
static int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathContextPtr ctx,
|
||||||
@ -931,7 +931,7 @@ static int directory_empty(const char* path)
|
|||||||
int result;
|
int result;
|
||||||
S3ObjList head;
|
S3ObjList head;
|
||||||
|
|
||||||
if((result = list_bucket(path, head, "/")) != 0){
|
if((result = list_bucket(path, head, "/", true)) != 0){
|
||||||
DPRNNN("list_bucket returns error.");
|
DPRNNN("list_bucket returns error.");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2254,7 +2254,7 @@ static int s3fs_readdir(const char* path, void* buf, fuse_fill_dir_t filler, off
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int list_bucket(const char* path, S3ObjList& head, const char* delimiter)
|
static int list_bucket(const char* path, S3ObjList& head, const char* delimiter, bool check_content_only)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
string s3_realpath;
|
string s3_realpath;
|
||||||
@ -2281,7 +2281,11 @@ static int list_bucket(const char* path, S3ObjList& head, const char* delimiter)
|
|||||||
}else{
|
}else{
|
||||||
query += urlEncode(s3_realpath.substr(1));
|
query += urlEncode(s3_realpath.substr(1));
|
||||||
}
|
}
|
||||||
query += "&max-keys=1000";
|
if (check_content_only){
|
||||||
|
query += "&max-keys=1";
|
||||||
|
}else{
|
||||||
|
query += "&max-keys=1000";
|
||||||
|
}
|
||||||
|
|
||||||
while(truncated){
|
while(truncated){
|
||||||
string each_query = query;
|
string each_query = query;
|
||||||
@ -2332,6 +2336,9 @@ static int list_bucket(const char* path, S3ObjList& head, const char* delimiter)
|
|||||||
|
|
||||||
// reset(initialize) curl object
|
// reset(initialize) curl object
|
||||||
s3fscurl.DestroyCurlHandle();
|
s3fscurl.DestroyCurlHandle();
|
||||||
|
|
||||||
|
if (check_content_only)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
S3FS_MALLOCTRIM(0);
|
S3FS_MALLOCTRIM(0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user