@@ -77,18 +77,19 @@ public Mono<Attachment> upload(UploadContext uploadContext) {
7777
7878 @ Override
7979 public Mono <Attachment > delete (DeleteContext deleteContext ) {
80- return Mono .just (deleteContext ).filter (context -> this .shouldHandle (context .policy ()))
80+ return Mono .just (deleteContext )
81+ .filter (context -> this .shouldHandle (context .policy ()))
8182 .flatMap (context -> {
8283 var objectKey = getObjectKey (context .attachment ());
8384 if (objectKey == null ) {
8485 log .warn (
8586 "Cannot obtain object key from attachment {}, skip deleting object from S3." ,
8687 context .attachment ().getMetadata ().getName ());
87- return Mono .just (context );
88+ return Mono .just (context . attachment () );
8889 } else if (MetadataUtil .nullSafeAnnotations (context .attachment ())
8990 .containsKey (SKIP_REMOTE_DELETION_ANNO )) {
9091 log .info ("Skip deleting object {} from S3." , objectKey );
91- return Mono .just (context );
92+ return Mono .just (context . attachment () );
9293 }
9394 var properties = S3OsProperties .convertFrom (deleteContext .configMap ());
9495 return Mono .using (
@@ -106,12 +107,11 @@ public Mono<Attachment> delete(DeleteContext deleteContext) {
106107 log .info ("Delete object {} from bucket {} successfully" ,
107108 objectKey , properties .getBucket ());
108109 })
109- .thenReturn (context );
110- })
111- // ignore when the object does not exist
112- .onErrorComplete (NoSuchKeyException .class ::isInstance )
113- .onErrorMap (S3ExceptionHandler ::map )
114- .thenReturn (deleteContext .attachment ());
110+ // ignore when the object does not exist
111+ .onErrorComplete (NoSuchKeyException .class ::isInstance )
112+ .onErrorMap (S3ExceptionHandler ::map )
113+ .thenReturn (context .attachment ());
114+ });
115115 }
116116
117117 @ Override
0 commit comments