chrisqiqiu commented on code in PR #64755:
URL: https://github.com/apache/airflow/pull/64755#discussion_r3068195361
##########
providers/google/src/airflow/providers/google/cloud/hooks/gcs.py:
##########
@@ -248,18 +256,30 @@ def rewrite(
source_object = source_bucket.blob(blob_name=source_object) # type:
ignore[attr-defined]
destination_bucket = client.bucket(destination_bucket)
- token, bytes_rewritten, total_bytes = destination_bucket.blob( #
type: ignore[attr-defined]
+ destination_blob = destination_bucket.blob( # type:
ignore[attr-defined]
blob_name=destination_object
- ).rewrite(source=source_object)
+ )
+
+ token, bytes_rewritten, total_bytes =
destination_blob.rewrite(source=source_object)
self.log.info("Total Bytes: %s | Bytes Written: %s", total_bytes,
bytes_rewritten)
while token is not None:
- token, bytes_rewritten, total_bytes = destination_bucket.blob( #
type: ignore[attr-defined]
- blob_name=destination_object
- ).rewrite(source=source_object, token=token)
+ token, bytes_rewritten, total_bytes =
destination_blob.rewrite(source=source_object, token=token)
self.log.info("Total Bytes: %s | Bytes Written: %s", total_bytes,
bytes_rewritten)
+
+ if retain_until_time is not None:
+ destination_blob.retention.mode = retention_mode or "Unlocked"
+ destination_blob.retention.retain_until_time = retain_until_time
+ destination_blob.patch()
Review Comment:
Added validation — retention_mode must be 'Locked'/'Unlocked' and requires
retain_until_time
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]