From 4eff6b4dd17e1e2fa804593f47d17e8fa14a44e4 Mon Sep 17 00:00:00 2001 From: Robb Kistler Date: Thu, 4 Feb 2016 22:57:33 -0800 Subject: [PATCH] Fix empty directory check against AWS S3 For ListBucketResult on an empty directory, AWS S3 and S3Proxy 1.4 differ. AWS will match the directory name, S3Proxy does not. Changing max-keys=1 to max-keys-2 works for both implementations. append_objects_from_xml() will swallow the directory key. The log level of this message is changed from ERROR to DBG. Fixes #345 --- src/s3fs.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 1a59a87..2b1a88c 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -2429,7 +2429,9 @@ static int list_bucket(const char* path, S3ObjList& head, const char* delimiter, query_prefix += urlEncode(s3_realpath.substr(1)); } if (check_content_only){ - query_maxkey += "max-keys=1"; + // Just need to know if there are child objects in dir + // For dir with children, expect "dir/" and "dir/child" + query_maxkey += "max-keys=2"; }else{ query_maxkey += "max-keys=1000"; } @@ -2568,7 +2570,7 @@ static int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathC } free(name); }else{ - S3FS_PRN_WARN("name is file or subdir in dir. but continue."); + S3FS_PRN_DBG("name is file or subdir in dir. but continue."); } xmlXPathFreeObject(key); }