mirror of
https://github.com/halo-dev/plugin-s3.git
synced 2025-10-17 16:08:25 +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);
|
||||
}
|
||||
var properties = S3OsProperties.convertFrom(deleteContext.configMap());
|
||||
return Mono.using(() -> buildS3Client(properties),
|
||||
return Mono.using(
|
||||
() -> buildS3Client(properties),
|
||||
client -> Mono.fromCallable(
|
||||
() -> client.deleteObject(DeleteObjectRequest.builder()
|
||||
.bucket(properties.getBucket())
|
||||
.key(objectKey)
|
||||
.build())).subscribeOn(Schedulers.boundedElastic()),
|
||||
S3Client::close)
|
||||
.build())),
|
||||
S3Client::close
|
||||
)
|
||||
.subscribeOn(Schedulers.boundedElastic())
|
||||
.doOnNext(response -> {
|
||||
checkResult(response, "delete object");
|
||||
log.info("Delete object {} from bucket {} successfully",
|
||||
@@ -105,8 +108,10 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
|
||||
})
|
||||
.thenReturn(context);
|
||||
})
|
||||
// ignore when the object does not exist
|
||||
.onErrorComplete(NoSuchKeyException.class::isInstance)
|
||||
.onErrorMap(S3ExceptionHandler::map)
|
||||
.map(DeleteContext::attachment);
|
||||
.thenReturn(deleteContext.attachment());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user