diff --git a/src/main/java/io/github/jiayaoO3O/finder/service/ComicService.java b/src/main/java/io/github/jiayaoO3O/finder/service/ComicService.java index 437f2121c..131786d50 100644 --- a/src/main/java/io/github/jiayaoO3O/finder/service/ComicService.java +++ b/src/main/java/io/github/jiayaoO3O/finder/service/ComicService.java @@ -76,7 +76,7 @@ private Consumer> photoEntitiesConsumer(ChapterEntity chapterE private Consumer photoExistsConsumer(ChapterEntity chapterEntity, PhotoEntity photoEntity, String photoPath) { return exists -> { if(exists) { - log.info("{}[{}]已存在, 跳过处理",taskService.clickPhotoCounter(false), photoPath); + log.info("{}[{}]已存在, 跳过处理", taskService.clickPhotoCounter(false), photoPath); } else { var bufferUni = taskService.processPhotoBuffer(photoEntity); bufferUni.subscribe() @@ -86,16 +86,18 @@ private Consumer photoExistsConsumer(ChapterEntity chapterEntity, Photo } private Consumer photoBufferConsumer(ChapterEntity chapterEntity, PhotoEntity photoEntity, String photoPath) { - return buffer -> taskService.processPhotoTempFile(buffer) + return buffer -> taskService.processPhotoTempFile(buffer, photoEntity) .subscribe() .with(this.tempFileConsumer(chapterEntity, photoEntity, photoPath)); } private Consumer tempFileConsumer(ChapterEntity chapterEntity, PhotoEntity photoEntity, String photoPath) { return path -> { - var bufferedImageUni = taskService.processPhotoReverse(path, chapterEntity, photoEntity); - bufferedImageUni.subscribe() - .with(this.finalImageConsumer(photoPath)); + if(StrUtil.isNotEmpty(path)) { + var bufferedImageUni = taskService.processPhotoReverse(path, chapterEntity, photoEntity); + bufferedImageUni.subscribe() + .with(this.finalImageConsumer(photoPath)); + } }; } diff --git a/src/main/java/io/github/jiayaoO3O/finder/service/TaskService.java b/src/main/java/io/github/jiayaoO3O/finder/service/TaskService.java index 8f2b1915e..fb577df16 100644 --- a/src/main/java/io/github/jiayaoO3O/finder/service/TaskService.java +++ b/src/main/java/io/github/jiayaoO3O/finder/service/TaskService.java @@ -8,9 +8,7 @@ import io.github.jiayaoO3O.finder.entity.PhotoEntity; import io.quarkus.runtime.Quarkus; import io.smallrye.common.constraint.NotNull; -import io.smallrye.mutiny.Multi; import io.smallrye.mutiny.Uni; -import io.smallrye.mutiny.tuples.Tuple2; import io.vertx.mutiny.core.Vertx; import io.vertx.mutiny.core.buffer.Buffer; import io.vertx.mutiny.ext.web.client.HttpResponse; @@ -158,8 +156,8 @@ public Uni processChapterDir(String title, ChapterEntity chapterEntity) .item(dirPath)); } - public Uni processPhotoExists(String photoPath){ - return vertx.fileSystem() + public Uni processPhotoExists(String photoPath) { + return vertx.fileSystem() .exists(photoPath); } @@ -170,16 +168,18 @@ public Uni processPhotoBuffer(PhotoEntity photoEntity) { .item(response.bodyAsBuffer())); } - public Uni processPhotoTempFile(Buffer buffer) { + public Uni processPhotoTempFile(Buffer buffer, PhotoEntity photoEntity) { if(buffer == null) { - log.info("buffer为null"); + log.info("{}[{}]对应buffer为null, 跳过处理", this.clickPhotoCounter(false), photoEntity.url()); + return Uni.createFrom() + .item(""); } var tempFile = vertx.fileSystem() .createTempFile(String.valueOf(System.nanoTime()), ".tmp"); var voidUni = tempFile.chain(path -> vertx.fileSystem() .writeFile(path, buffer) .onFailure() - .invoke(e -> log.error(StrUtil.format("保存文件:[{}]失败:[{}]", path, e.getLocalizedMessage()), e)) + .invoke(e -> log.error(StrUtil.format("保存文件:[{}]失败:[{}]", photoEntity.url(), e.getLocalizedMessage()), e)) .onItem() .transform(v -> path)); return voidUni; @@ -362,6 +362,7 @@ public void write(String path, BufferedImage bufferedImage) { log.error(StrUtil.format("{}保存文件失败:[{}][{}]", this.clickPhotoCounter(false), path, e.getLocalizedMessage()), e); } } + /** * @param body 网页的html内容. * @return 漫画的标题.