Skip to content

Commit 5187dcb

Browse files
committed
feat(storage): migrate deleteSourceObjects to native GCS request body parameter
1 parent 26e992e commit 5187dcb

3 files changed

Lines changed: 4 additions & 49 deletions

File tree

Storage/src/Bucket.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,35 +1187,11 @@ public function compose(array $sourceObjects, $name, array $options = [])
11871187
throw new \InvalidArgumentException('A content type could not be detected and must be provided manually.');
11881188
}
11891189

1190-
$deleteSourceObjects = $options['deleteSourceObjects'] ?? false;
1191-
1192-
if (!is_bool($deleteSourceObjects)) {
1193-
throw new \InvalidArgumentException('The deleteSourceObjects option should be a boolean.');
1194-
}
1195-
11961190
unset($options['metadata']);
11971191
unset($options['predefinedAcl']);
11981192

11991193
$response = $this->connection->composeObject(array_filter($options));
12001194

1201-
if ($deleteSourceObjects) {
1202-
$deleteOptions = array_filter([
1203-
'userProject' => $this->identity['userProject']
1204-
]);
1205-
1206-
foreach ($sourceObjects as $sourceObject) {
1207-
try {
1208-
if ($sourceObject instanceof StorageObject) {
1209-
$sourceObject->delete($deleteOptions);
1210-
} else {
1211-
$this->object($sourceObject)->delete($deleteOptions);
1212-
}
1213-
} catch (NotFoundException $e) {
1214-
// Gracefully ignore duplicate source files or parallel deletions
1215-
}
1216-
}
1217-
}
1218-
12191195
return new StorageObject(
12201196
$this->connection,
12211197
$response['name'],

Storage/src/Connection/ServiceDefinition/storage-v1.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,10 @@
897897
"$ref": "Object",
898898
"description": "Properties of the resulting object."
899899
},
900+
"deleteSourceObjects": {
901+
"type": "boolean",
902+
"description": "If true, the source objects will be deleted after a successful compose operation."
903+
},
900904
"kind": {
901905
"type": "string",
902906
"description": "The kind of item this is.",
@@ -4398,11 +4402,6 @@
43984402
"type": "string",
43994403
"description": "The project to be billed for this request. Required for Requester Pays buckets.",
44004404
"location": "query"
4401-
},
4402-
"deleteSourceObjects": {
4403-
"type": "boolean",
4404-
"description": "If true, the source objects will be deleted after a successful compose operation.",
4405-
"location": "query"
44064405
}
44074406
},
44084407
"parameterOrder": [

Storage/tests/Unit/BucketTest.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -387,16 +387,6 @@ public function testComposeThrowsExceptionWithUnknownContentType()
387387
$bucket->compose(['file1.txt', 'file2.txt'], 'combined-files.abc');
388388
}
389389

390-
public function testComposeThrowsExceptionWithInvalidDeleteSourceObjects()
391-
{
392-
$this->expectException(InvalidArgumentException::class);
393-
394-
$bucket = $this->getBucket();
395-
396-
$bucket->compose(['file1.txt', 'file2.txt'], 'combined-files.txt', [
397-
'deleteSourceObjects' => 'not-a-boolean'
398-
]);
399-
}
400390

401391
/**
402392
* @dataProvider composeProvider
@@ -448,16 +438,6 @@ public function testComposeWithDeleteSourceObjects()
448438
])
449439
->shouldBeCalledTimes(1);
450440

451-
$this->connection->deleteObject([
452-
'bucket' => self::BUCKET_NAME,
453-
'object' => 'file1.txt'
454-
])->shouldBeCalledTimes(1);
455-
456-
$this->connection->deleteObject([
457-
'bucket' => self::BUCKET_NAME,
458-
'object' => 'file2.txt'
459-
])->shouldBeCalledTimes(1);
460-
461441
$bucket = $this->getBucket();
462442

463443
$object = $bucket->compose(['file1.txt', 'file2.txt'], $destinationObject, [

0 commit comments

Comments
 (0)