Commit 0dc13500 by rfkelly0

S3FS: correct verifying of buckets when IAM policy is applied.

This fixes Issue 120.
parent 2afb6e1f
...@@ -139,7 +139,14 @@ class S3FS(FS): ...@@ -139,7 +139,14 @@ class S3FS(FS):
return b return b
except AttributeError: except AttributeError:
try: try:
b = self._s3conn.get_bucket(self._bucket_name, validate=True) # Validate by listing the bucket if there is no prefix.
# If there is a prefix, validate by listing only the prefix
# itself, to avoid errors when an IAM policy has been applied.
if self._prefix:
b = self._s3conn.get_bucket(self._bucket_name, validate=0)
b.get_key(self._prefix)
else:
b = self._s3conn.get_bucket(self._bucket_name, validate=1)
except S3ResponseError, e: except S3ResponseError, e:
if "404 Not Found" not in str(e): if "404 Not Found" not in str(e):
raise raise
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment