Skip to content

Commit

Permalink
skip deleting object from S3
Browse files Browse the repository at this point in the history
  • Loading branch information
longjuan committed Nov 27, 2023
1 parent 660a874 commit e8f2e9f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/run/halo/s3os/S3OsAttachmentHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,14 @@ public Mono<Attachment> delete(DeleteContext deleteContext) {
return Mono.just(deleteContext).filter(context -> this.shouldHandle(context.policy()))
.flatMap(context -> {
var objectKey = getObjectKey(context.attachment());
if (objectKey == null || MetadataUtil.nullSafeAnnotations(context.attachment())
if (objectKey == null) {
log.warn(
"Cannot obtain object key from attachment {}, skip deleting object from S3.",
context.attachment().getMetadata().getName());
return Mono.just(context);
} else if (MetadataUtil.nullSafeAnnotations(context.attachment())
.containsKey(SKIP_REMOTE_DELETION_ANNO)) {
log.info("Skip deleting object {} from S3.", objectKey);
return Mono.just(context);
}
var properties = getProperties(deleteContext.configMap());
Expand Down

0 comments on commit e8f2e9f

Please sign in to comment.