Skip to content

Commit

Permalink
fix cloud path references
Browse files Browse the repository at this point in the history
  • Loading branch information
msmitherdc committed Aug 29, 2024
1 parent 03c5d34 commit d020b0e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions cloudpathlib/s3/s3client.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def __init__(
def _get_metadata(self, cloud_path: S3Path) -> Dict[str, Any]:
# get accepts all download extra args
size = None
path = f"s3://{cloud_path.bucket}/{cloud_path.key}"
size = self._metadata_cache[cloud_path].size
if size:
return {
Expand All @@ -171,7 +170,7 @@ def _get_metadata(self, cloud_path: S3Path) -> Dict[str, Any]:
data = self.s3.ObjectSummary(cloud_path.bucket, cloud_path.key).get(
**self.boto3_dl_extra_args
)
self._set_metadata_cache(path, "file", data["ETag"], data["ContentLength"], data["LastModified"])
self._set_metadata_cache(cloud_path, "file", data["ETag"], data["ContentLength"], data["LastModified"])
return {
"last_modified": data["LastModified"],
"size": data["ContentLength"],
Expand Down Expand Up @@ -289,7 +288,7 @@ def _list_dir(self, cloud_path: S3Path, recursive=False) -> Iterable[Tuple[S3Pat
parent_canonical = prefix + str(parent).rstrip("/")
if parent_canonical not in yielded_dirs and str(parent) != ".":
path = self.CloudPath(f"s3://{cloud_path.bucket}/{parent_canonical}")
self._set_metadata_cache(path, "dir", etag, size, last_modified)
self._set_metadata_cache(cloud_path, "dir", etag, size, last_modified)
yield (
path,
True,
Expand All @@ -304,7 +303,7 @@ def _list_dir(self, cloud_path: S3Path, recursive=False) -> Iterable[Tuple[S3Pat
# s3 fake directories have 0 size and end with "/"
if result_key.get("Key").endswith("/") and result_key.get("Size") == 0:
path = self.CloudPath(f"s3://{cloud_path.bucket}/{canonical}")
self._set_metadata_cache(path, "dir", etag, size, last_modified)
self._set_metadata_cache(cloud_path, "dir", etag, size, last_modified)
yield (
path,
True,
Expand All @@ -314,7 +313,7 @@ def _list_dir(self, cloud_path: S3Path, recursive=False) -> Iterable[Tuple[S3Pat
# yield object as file
else:
path = self.CloudPath(f"s3://{cloud_path.bucket}/{result_key.get('Key')}")
self._set_metadata_cache(path, "file", etag, size, last_modified)
self._set_metadata_cache(cloud_path, "file", etag, size, last_modified)
yield (
path,
False,
Expand Down

0 comments on commit d020b0e

Please sign in to comment.