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){