Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/main/java/run/halo/s3os/S3OsAttachmentHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,27 @@ public Mono<Attachment> delete(DeleteContext deleteContext) {
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",
objectKey, properties.getBucket());
})
.thenReturn(context);
})
// ignore when the object does not exist
.onErrorComplete(NoSuchKeyException.class::isInstance)
.onErrorMap(S3ExceptionHandler::map)
.map(DeleteContext::attachment);
.thenReturn(deleteContext.attachment());
}

@Override
Expand Down