mirror of
https://github.com/halo-dev/plugin-s3.git
synced 2025-10-18 16:41:29 +00:00
Ignore non-existing object when deleting (#193)
This commit is contained in:
@@ -91,13 +91,16 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
|
|||||||
return Mono.just(context);
|
return Mono.just(context);
|
||||||
}
|
}
|
||||||
var properties = S3OsProperties.convertFrom(deleteContext.configMap());
|
var properties = S3OsProperties.convertFrom(deleteContext.configMap());
|
||||||
return Mono.using(() -> buildS3Client(properties),
|
return Mono.using(
|
||||||
|
() -> buildS3Client(properties),
|
||||||
client -> Mono.fromCallable(
|
client -> Mono.fromCallable(
|
||||||
() -> client.deleteObject(DeleteObjectRequest.builder()
|
() -> client.deleteObject(DeleteObjectRequest.builder()
|
||||||
.bucket(properties.getBucket())
|
.bucket(properties.getBucket())
|
||||||
.key(objectKey)
|
.key(objectKey)
|
||||||
.build())).subscribeOn(Schedulers.boundedElastic()),
|
.build())),
|
||||||
S3Client::close)
|
S3Client::close
|
||||||
|
)
|
||||||
|
.subscribeOn(Schedulers.boundedElastic())
|
||||||
.doOnNext(response -> {
|
.doOnNext(response -> {
|
||||||
checkResult(response, "delete object");
|
checkResult(response, "delete object");
|
||||||
log.info("Delete object {} from bucket {} successfully",
|
log.info("Delete object {} from bucket {} successfully",
|
||||||
@@ -105,8 +108,10 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
|
|||||||
})
|
})
|
||||||
.thenReturn(context);
|
.thenReturn(context);
|
||||||
})
|
})
|
||||||
|
// ignore when the object does not exist
|
||||||
|
.onErrorComplete(NoSuchKeyException.class::isInstance)
|
||||||
.onErrorMap(S3ExceptionHandler::map)
|
.onErrorMap(S3ExceptionHandler::map)
|
||||||
.map(DeleteContext::attachment);
|
.thenReturn(deleteContext.attachment());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user