Skip to content

Commit 178694c

Browse files
feat(storage): support delete_source_objects in compose API
Implements the delete_source_objects parameter in Blob.compose() to allow automatic deletion of source objects upon successful composition. Also adds unit and system tests to verify the new parameter. Reference PR: googleapis/google-cloud-java#12873 Co-authored-by: nidhiii-27 <224584462+nidhiii-27@users.noreply.github.com>
1 parent f23963c commit 178694c

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

packages/google-cloud-storage/tests/system/test_blob.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,26 @@ def test_blob_compose_new_blob(shared_bucket, blobs_to_delete):
853853
assert destination.download_as_bytes() == payload_1 + payload_2
854854

855855

856+
def test_blob_compose_delete_source_objects(shared_bucket, blobs_to_delete):
857+
payload_1 = b"AAA\n"
858+
source_1 = shared_bucket.blob("source-1-delete")
859+
source_1.upload_from_string(payload_1)
860+
blobs_to_delete.append(source_1)
861+
862+
payload_2 = b"BBB\n"
863+
source_2 = shared_bucket.blob("source-2-delete")
864+
source_2.upload_from_string(payload_2)
865+
blobs_to_delete.append(source_2)
866+
867+
destination = shared_bucket.blob("destination-delete")
868+
destination.compose([source_1, source_2], delete_source_objects=True)
869+
blobs_to_delete.append(destination)
870+
871+
assert destination.download_as_bytes() == payload_1 + payload_2
872+
assert not source_1.exists()
873+
assert not source_2.exists()
874+
875+
856876
def test_blob_compose_new_blob_wo_content_type(shared_bucket, blobs_to_delete):
857877
payload_1 = b"AAA\n"
858878
source_1 = shared_bucket.blob("source-1")

0 commit comments

Comments
 (0)