2 Commits

Author SHA1 Message Date
John Niang
42e27da86b Ignore non-existing object when deleting (#193) 2025-06-11 00:24:19 +08:00
John Niang
19469d0537 Upgrade Halo Gradle plugin to 0.6.0 (#192) 2025-06-11 00:20:41 +08:00
3 changed files with 10 additions and 16 deletions

View File

@@ -1,17 +1,8 @@
// TODO Remove the buildscript block when the halo devtools plugin is updated to use ASM 9.5 or later.
buildscript {
dependencies {
// force the version of ASM used by the halo devtools plugin
classpath('org.ow2.asm:asm:9.8')
classpath('org.ow2.asm:asm-commons:9.8')
}
}
plugins {
id 'java'
id "com.github.node-gradle.node" version "7.1.0"
id "io.freefair.lombok" version "8.13.1"
id "run.halo.plugin.devtools" version "0.5.0"
id "run.halo.plugin.devtools" version "0.6.0"
id 'org.openapi.generator' version '7.12.0'
}

View File

@@ -1,6 +1,5 @@
pluginManagement {
repositories {
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/spring-plugin' }
@@ -9,4 +8,3 @@ pluginManagement {
}
}
rootProject.name = 'plugin-s3'

View File

@@ -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