From 027372d6c4c7375197431ebeb5250159a50360d4 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Thu, 31 Mar 2022 13:49:11 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B3=B5=EC=A7=80=EC=82=AC=ED=95=AD=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EB=B0=98=EC=98=81=20-=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=82=AD=EC=A0=9C=EC=8B=9C=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EC=98=A4=EB=A5=98=EB=8A=94=20skip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/biz/ctgy/service/impl/CtgyFileService.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/xit/biz/ctgy/service/impl/CtgyFileService.java b/src/main/java/com/xit/biz/ctgy/service/impl/CtgyFileService.java index 6bb6f1c..b495857 100644 --- a/src/main/java/com/xit/biz/ctgy/service/impl/CtgyFileService.java +++ b/src/main/java/com/xit/biz/ctgy/service/impl/CtgyFileService.java @@ -131,16 +131,19 @@ public class CtgyFileService implements ICtgyFileService { public void removePublicBoardFile(Long inCode) { MinInfoBoard680 savedEntity = repository.findById(inCode).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND)); + repository.delete(savedEntity); - File file = null; + // 정보 삭제후 파일 삭제 : 에러 발생시 skip if(Checks.isNotEmpty(savedEntity.getInFilename())){ String absFile = rootPath + savedEntity.getInFileurl().split(serviceUrl)[1]+File.separator + savedEntity.getInFilename(); - file = new File(absFile); + try { + File file = new File(absFile); + if (Checks.isNotEmpty(file) && file.exists()) file.delete(); + }catch(Exception e){ + // + } } - // 정보 삭제후 파일 삭제 - repository.deleteById(inCode); - if(file.exists()) file.delete(); } private void setEntity(MinInfoBoard680 savedEntity, MinInfoBoard680 entity){