mirror of
https://github.com/halo-dev/plugin-s3.git
synced 2025-10-15 14:40:46 +00:00
Compare commits
1 Commits
bug/attach
...
v1.13.1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0f4e69e0df |
@@ -77,18 +77,19 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<Attachment> delete(DeleteContext deleteContext) {
|
public Mono<Attachment> delete(DeleteContext deleteContext) {
|
||||||
return Mono.just(deleteContext).filter(context -> this.shouldHandle(context.policy()))
|
return Mono.just(deleteContext)
|
||||||
|
.filter(context -> this.shouldHandle(context.policy()))
|
||||||
.flatMap(context -> {
|
.flatMap(context -> {
|
||||||
var objectKey = getObjectKey(context.attachment());
|
var objectKey = getObjectKey(context.attachment());
|
||||||
if (objectKey == null) {
|
if (objectKey == null) {
|
||||||
log.warn(
|
log.warn(
|
||||||
"Cannot obtain object key from attachment {}, skip deleting object from S3.",
|
"Cannot obtain object key from attachment {}, skip deleting object from S3.",
|
||||||
context.attachment().getMetadata().getName());
|
context.attachment().getMetadata().getName());
|
||||||
return Mono.just(context);
|
return Mono.just(context.attachment());
|
||||||
} else if (MetadataUtil.nullSafeAnnotations(context.attachment())
|
} else if (MetadataUtil.nullSafeAnnotations(context.attachment())
|
||||||
.containsKey(SKIP_REMOTE_DELETION_ANNO)) {
|
.containsKey(SKIP_REMOTE_DELETION_ANNO)) {
|
||||||
log.info("Skip deleting object {} from S3.", objectKey);
|
log.info("Skip deleting object {} from S3.", objectKey);
|
||||||
return Mono.just(context);
|
return Mono.just(context.attachment());
|
||||||
}
|
}
|
||||||
var properties = S3OsProperties.convertFrom(deleteContext.configMap());
|
var properties = S3OsProperties.convertFrom(deleteContext.configMap());
|
||||||
return Mono.using(
|
return Mono.using(
|
||||||
@@ -106,12 +107,11 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
|
|||||||
log.info("Delete object {} from bucket {} successfully",
|
log.info("Delete object {} from bucket {} successfully",
|
||||||
objectKey, properties.getBucket());
|
objectKey, properties.getBucket());
|
||||||
})
|
})
|
||||||
.thenReturn(context);
|
// ignore when the object does not exist
|
||||||
})
|
.onErrorComplete(NoSuchKeyException.class::isInstance)
|
||||||
// ignore when the object does not exist
|
.onErrorMap(S3ExceptionHandler::map)
|
||||||
.onErrorComplete(NoSuchKeyException.class::isInstance)
|
.thenReturn(context.attachment());
|
||||||
.onErrorMap(S3ExceptionHandler::map)
|
});
|
||||||
.thenReturn(deleteContext.attachment());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user