From 037165e57e45bd52def2405ad84f4b9f49294f7c Mon Sep 17 00:00:00 2001 From: Sanghoon Jeong <67852689+wjdtkdgns@users.noreply.github.com> Date: Fri, 25 Aug 2023 11:13:29 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=ED=9C=B4=EC=A7=80=ED=86=B5=20=EB=B9=84?= =?UTF-8?q?=EC=9A=B0=EA=B8=B0=20s3=20object=20list=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95=20(#137)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [fix] s3 object list 생성 로직 수정 #136 * [chore] spotless 적용 #136 --- .../service/ClearDeletedObjectUseCase.java | 20 ++++++++++--------- .../service/ClearOldDeletedObjectUseCase.java | 20 ++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Api/src/main/java/allchive/server/api/recycle/service/ClearDeletedObjectUseCase.java b/Api/src/main/java/allchive/server/api/recycle/service/ClearDeletedObjectUseCase.java index 468c2ee8..335f682f 100644 --- a/Api/src/main/java/allchive/server/api/recycle/service/ClearDeletedObjectUseCase.java +++ b/Api/src/main/java/allchive/server/api/recycle/service/ClearDeletedObjectUseCase.java @@ -60,17 +60,19 @@ public void execute(ClearDeletedObjectRequest request) { private void deleteS3Object(List contents, List archivings) { List imageKeys = - archivings.stream() - .map(Archiving::getImageUrl) + new ArrayList<>( + archivings.stream() + .map(Archiving::getImageUrl) + .filter(url -> !url.isEmpty()) + .filter(url -> !url.startsWith("http")) + .toList()); + imageKeys.addAll( + contents.stream() + .filter(content -> content.getContentType().equals(ContentType.IMAGE)) + .map(Content::getImageUrl) .filter(url -> !url.isEmpty()) .filter(url -> !url.startsWith("http")) - .toList(); - contents.stream() - .filter(content -> content.getContentType().equals(ContentType.IMAGE)) - .map(Content::getImageUrl) - .filter(url -> !url.startsWith("http")) - .filter(url -> !url.isEmpty()) - .forEach(imageKeys::add); + .toList()); s3DeleteObjectService.deleteS3Object(imageKeys); } diff --git a/Api/src/main/java/allchive/server/api/recycle/service/ClearOldDeletedObjectUseCase.java b/Api/src/main/java/allchive/server/api/recycle/service/ClearOldDeletedObjectUseCase.java index 106ab361..b6d5ccc7 100644 --- a/Api/src/main/java/allchive/server/api/recycle/service/ClearOldDeletedObjectUseCase.java +++ b/Api/src/main/java/allchive/server/api/recycle/service/ClearOldDeletedObjectUseCase.java @@ -63,17 +63,19 @@ public void executeSchedule() { private void deleteS3Object(List contents, List archivings) { List imageKeys = - archivings.stream() - .map(Archiving::getImageUrl) + new ArrayList<>( + archivings.stream() + .map(Archiving::getImageUrl) + .filter(url -> !url.isEmpty()) + .filter(url -> !url.startsWith("http")) + .toList()); + imageKeys.addAll( + contents.stream() + .filter(content -> content.getContentType().equals(ContentType.IMAGE)) + .map(Content::getImageUrl) .filter(url -> !url.isEmpty()) .filter(url -> !url.startsWith("http")) - .toList(); - contents.stream() - .filter(content -> content.getContentType().equals(ContentType.IMAGE)) - .map(Content::getImageUrl) - .filter(url -> !url.isEmpty()) - .filter(url -> !url.startsWith("http")) - .forEach(imageKeys::add); + .toList()); s3DeleteObjectService.deleteS3Object(imageKeys); }