Skip to content

Commit 89ae18a

Browse files
committed
copyBlob: use "destination" instead of "target"
1 parent 27656b2 commit 89ae18a

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3BlobContainer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ public void writeBlobAtomic(OperationPurpose purpose, String blobName, BytesRefe
326326
* See <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html">CopyObject</a>.
327327
* @param purpose The purpose of the operation
328328
* @param sourceBlobName The name of the blob to copy from
329-
* @param targetBlobContainer The blob container to copy the blob into
330-
* @param targetBlobName The name of the blob to copy to
329+
* @param destinationBlobContainer The blob container to copy the blob into
330+
* @param destinationBlobName The name of the blob to copy to
331331
* @param failIfAlreadyExists Whether to throw a FileAlreadyExistsException if the target blob already exists
332332
* On S3, if true, throws UnsupportedOperationException because we don't know how
333333
* to do this atomically.
@@ -337,27 +337,27 @@ public void writeBlobAtomic(OperationPurpose purpose, String blobName, BytesRefe
337337
public void copyBlob(
338338
OperationPurpose purpose,
339339
String sourceBlobName,
340-
BlobContainer targetBlobContainer,
341-
String targetBlobName,
340+
BlobContainer destinationBlobContainer,
341+
String destinationBlobName,
342342
boolean failIfAlreadyExists
343343
) throws IOException {
344344
assert BlobContainer.assertPurposeConsistency(purpose, sourceBlobName);
345-
assert BlobContainer.assertPurposeConsistency(purpose, targetBlobName);
346-
if (targetBlobContainer instanceof S3BlobContainer == false) {
345+
assert BlobContainer.assertPurposeConsistency(purpose, destinationBlobName);
346+
if (destinationBlobContainer instanceof S3BlobContainer == false) {
347347
throw new IllegalArgumentException("target blob container must be a S3BlobContainer");
348348
}
349349
if (failIfAlreadyExists) {
350350
throw new UnsupportedOperationException("S3 blob container does not support failIfAlreadyExists");
351351
}
352352

353-
final var s3TargetBlobContainer = (S3BlobContainer) targetBlobContainer;
353+
final var s3TargetBlobContainer = (S3BlobContainer) destinationBlobContainer;
354354

355355
// metadata is inherited from source, but not canned ACL or storage class
356356
final CopyObjectRequest copyRequest = new CopyObjectRequest(
357357
blobStore.bucket(),
358358
buildKey(sourceBlobName),
359359
s3TargetBlobContainer.blobStore.bucket(),
360-
s3TargetBlobContainer.buildKey(targetBlobName)
360+
s3TargetBlobContainer.buildKey(destinationBlobName)
361361
).withCannedAccessControlList(blobStore.getCannedACL()).withStorageClass(blobStore.getStorageClass());
362362

363363
S3BlobStore.configureRequestForMetrics(copyRequest, blobStore, Operation.COPY_OBJECT, purpose);

server/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ default void writeBlobAtomic(OperationPurpose purpose, String blobName, BytesRef
185185
*
186186
* @param purpose The purpose of the operation
187187
* @param sourceBlobName The name of the blob to copy from
188-
* @param targetBlobContainer The blob container to copy the blob into
189-
* @param targetBlobName The name of the blob to copy to
188+
* @param destinationBlobContainer The blob container to copy the blob into
189+
* @param destinationBlobName The name of the blob to copy to
190190
* @param failIfAlreadyExists Whether to throw a FileAlreadyExistsException if the target blob already exists
191191
* @throws NoSuchFileException If the source blob does not exist
192192
* @throws FileAlreadyExistsException If failIfAlreadyExists is true and the target blob already exists
@@ -195,8 +195,8 @@ default void writeBlobAtomic(OperationPurpose purpose, String blobName, BytesRef
195195
default void copyBlob(
196196
OperationPurpose purpose,
197197
String sourceBlobName,
198-
BlobContainer targetBlobContainer,
199-
String targetBlobName,
198+
BlobContainer destinationBlobContainer,
199+
String destinationBlobName,
200200
boolean failIfAlreadyExists
201201
) throws IOException {
202202
throw new UnsupportedOperationException("this blob container does not support copy");

server/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobContainer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,20 +353,20 @@ public void writeBlobAtomic(OperationPurpose purpose, final String blobName, Byt
353353
public void copyBlob(
354354
OperationPurpose purpose,
355355
String sourceBlobName,
356-
BlobContainer targetBlobContainer,
357-
String targetBlobName,
356+
BlobContainer destinationBlobContainer,
357+
String destinationBlobName,
358358
boolean failIfAlreadyExists
359359
) throws IOException {
360-
if (targetBlobContainer instanceof FsBlobContainer == false) {
360+
if (destinationBlobContainer instanceof FsBlobContainer == false) {
361361
throw new IllegalArgumentException("targetBlobContainer must be a FsBlobContainer");
362362
}
363-
final FsBlobContainer targetContainer = (FsBlobContainer) targetBlobContainer;
363+
final FsBlobContainer targetContainer = (FsBlobContainer) destinationBlobContainer;
364364
final Path sourceBlobPath = path.resolve(sourceBlobName);
365-
final String tempBlob = tempBlobName(targetBlobName);
365+
final String tempBlob = tempBlobName(destinationBlobName);
366366
final Path tempBlobPath = targetContainer.path.resolve(tempBlob);
367367
Files.copy(sourceBlobPath, tempBlobPath, StandardCopyOption.REPLACE_EXISTING);
368368
try {
369-
targetContainer.moveBlobAtomic(purpose, tempBlob, targetBlobName, failIfAlreadyExists);
369+
targetContainer.moveBlobAtomic(purpose, tempBlob, destinationBlobName, failIfAlreadyExists);
370370
} catch (IOException ex) {
371371
try {
372372
targetContainer.deleteBlobsIgnoringIfNotExists(purpose, Iterators.single(tempBlob));

0 commit comments

Comments
 (0)