Skip to content

Commit

Permalink
[Fix] 리뷰 삭제 시 이미지가 삭제되지 않던 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ImKEISS committed Oct 28, 2024
1 parent 2812e85 commit 7981c5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/appcenter/BJJ/domain/image/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public class Image {

private String name;

// 이미지 확장자
private String type;

// 이미지 최종 경로 이름 (review, cafeteria..)
private String path;

@ManyToOne(fetch = FetchType.LAZY)
Expand Down Expand Up @@ -79,8 +81,8 @@ public static Image of(MultipartFile file, Review review, String folderPath) thr
.build();
}

public boolean removeImageFromPath() {
File file = new File(path);
public boolean removeImageFromPath(String folderPath) {
File file = new File(folderPath, name);
return file.delete();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public Long delete(Long reviewId) {
Review review = optionalReview.get();

review.getImages().forEach(image -> {
boolean result = image.removeImageFromPath();
boolean result = image.removeImageFromPath(REVIEW_IMG_DIR);

if (!result) {
log.info("이미지 {} 삭제에 실패했습니다.", image.getName());
Expand Down

0 comments on commit 7981c5a

Please sign in to comment.