-
Notifications
You must be signed in to change notification settings - Fork 116
Move the bucket versioning request into S3Core #1098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -835,6 +835,23 @@ def delete_bucket(self, bucket: str, **params) -> None: | |
| _logger.debug(f"Delete bucket: s3://{bucket}") | ||
| self.call(self._client.delete_bucket, Bucket=bucket, **params) | ||
|
|
||
| def get_bucket_versioning(self, bucket: str, **params) -> str | None: | ||
| """Get the versioning state of a bucket with GetBucketVersioning. | ||
|
|
||
| Args: | ||
| bucket: The name of the bucket. | ||
| **params: Additional request parameters, sent as given. | ||
|
|
||
| Returns: | ||
| ``Enabled`` or ``Suspended``, or None if versioning has never | ||
| been enabled on the bucket. | ||
|
|
||
| Raises: | ||
| FileNotFoundError: If the bucket does not exist. | ||
| """ | ||
| response = self.call(self._client.get_bucket_versioning, Bucket=bucket, **params) | ||
| return cast(str | None, response.get("Status")) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Self-review round two (claims, callers, operations): CLEAN
|
||
|
|
||
| def delete_object(self, path: S3Path, **params) -> None: | ||
| """Delete an object, or a version of it, with DeleteObject. | ||
|
|
||
|
|
@@ -1266,7 +1283,7 @@ def plan_multipart_copy( | |
| request.pop("Tagging", None) | ||
| # Directory buckets do not support GetObjectTagging, and their | ||
| # objects have no tags. | ||
| if not self._is_directory_bucket(source.bucket): | ||
| if not source.is_directory_bucket: | ||
| tags = self.get_object_tagging( | ||
| source, **self.operation_params("get_object_tagging", source_params) | ||
| ) | ||
|
|
@@ -1290,7 +1307,7 @@ def plan_multipart_copy( | |
| ) | ||
| if annotation_directive == "COPY" | ||
| and "CopySourceSSECustomerAlgorithm" not in params | ||
| and not self._is_directory_bucket(source.bucket) | ||
| and not source.is_directory_bucket | ||
| else () | ||
| ) | ||
| return S3MultipartCopyPlan( | ||
|
|
@@ -1604,20 +1621,6 @@ def generate_presigned_url( | |
| ), | ||
| ) | ||
|
|
||
| @staticmethod | ||
| def _is_directory_bucket(bucket: str) -> bool: | ||
| """Return whether the bucket is a directory bucket (S3 Express One Zone). | ||
|
|
||
| Directory bucket names end with ``--x-s3``. | ||
|
|
||
| Args: | ||
| bucket: S3 bucket name. | ||
|
|
||
| Returns: | ||
| True if the bucket is a directory bucket. | ||
| """ | ||
| return bucket.endswith("--x-s3") | ||
|
|
||
| @staticmethod | ||
| def _copy_source_params(params: Mapping[str, Any]) -> dict[str, Any]: | ||
| """Map the parameters of a copy to those of the requests that read its source. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,14 @@ def is_bucket(self) -> bool: | |
| """Whether the path names the bucket: it has no key, or a key of only slashes.""" | ||
| return not self.key or not self.key.strip("/") | ||
|
|
||
| @property | ||
| def is_directory_bucket(self) -> bool: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent review and /code-review at
|
||
| """Whether the bucket is a directory bucket (S3 Express One Zone). | ||
|
|
||
| The names of directory buckets end with ``--x-s3``. | ||
| """ | ||
| return self.bucket.endswith("--x-s3") | ||
|
|
||
| @property | ||
| def name(self) -> str: | ||
| """The path without a scheme or version, in ``bucket/key`` form, or the bucket.""" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review round one (implementation behavior): CLEAN
47fb6f31749f505a723c314b03ebf1ca3c5b8114, heade12d5d584c0f5b6f6ff7944585ca66941be18e1a._move_pairs()sends the same GetBucketVersioning, once per distinct candidate bucket.self._call(self._client.get_bucket_versioning, Bucket=...), which delegated toS3Core.call().S3Core.get_bucket_versioning(), which sendsself.call(self._client.get_bucket_versioning, Bucket=..., **params).request_kwargsand the error translation are therefore unchanged."Enabled"is unchanged;Noneand"Suspended"still mean the bucket is not versioning-enabled.S3Path.is_directory_bucketapplies the same--x-s3suffix rule to the same bucket name at all three former call sites. These are the adapter's candidate filter and the two checks inplan_multipart_copy().mvtests now set_sync_fs._call = _sync_fs._core.call, as the other tests do.test_mv_null_version_onto_keyfail.S3Core._is_directory_bucket()(repository grep).