GDAL Validation FIX
This commit is contained in:
@@ -35,7 +35,6 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -49,8 +48,8 @@ public class MapSheetMngFileCheckerService {
|
||||
private final FileConfig fileConfig;
|
||||
private final MapSheetMngFileRepository mapSheetMngFileRepository;
|
||||
|
||||
@Value("${mapsheet.upload.skipGdalValidation:false}")
|
||||
private boolean skipGdalValidation;
|
||||
// @Value("${mapsheet.upload.skipGdalValidation:false}")
|
||||
// private boolean skipGdalValidation;
|
||||
|
||||
public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
|
||||
|
||||
@@ -339,9 +338,20 @@ public class MapSheetMngFileCheckerService {
|
||||
? Paths.get(baseName + ".tif")
|
||||
: path.getParent().resolve(baseName + ".tif");
|
||||
|
||||
// 이미 존재하는 경우 처리
|
||||
if (Files.exists(path) && !overwrite) {
|
||||
throw new DuplicateFileException("동일한 파일이 이미 존재합니다: " + path.getFileName());
|
||||
// DB 중복 체크
|
||||
String parentPathStr = path.getParent() != null ? path.getParent().toString() : "";
|
||||
boolean dbExists =
|
||||
mapSheetMngFileRepository.existsByFileNameAndFilePath(filename, parentPathStr);
|
||||
// boolean fileExists = Files.exists(path); // 파일 시스템 존재 여부는 체크하지 않음 (DB 기준)
|
||||
|
||||
// 이미 존재하는 경우 처리 (DB에만 있는 경우 체크)
|
||||
if (!overwrite && dbExists) {
|
||||
throw new DuplicateFileException("동일한 파일이 이미 존재합니다 (DB): " + path.getFileName());
|
||||
}
|
||||
|
||||
// 덮어쓰기인 경우 기존 DB 데이터 삭제 (새로 저장하기 위함)
|
||||
if (overwrite && dbExists) {
|
||||
mapSheetMngFileRepository.deleteByFileNameAndFilePath(filename, parentPathStr);
|
||||
}
|
||||
|
||||
// 업로드 파일 저장(덮어쓰기 허용 시 replace)
|
||||
@@ -367,14 +377,13 @@ public class MapSheetMngFileCheckerService {
|
||||
}
|
||||
|
||||
if ("tif".equals(ext) || "tiff".equals(ext)) {
|
||||
// GDAL 검증 (플래그에 따라 스킵)
|
||||
if (!skipGdalValidation) {
|
||||
boolean isValidTif = FIleChecker.cmmndGdalInfo(path.toString());
|
||||
if (!isValidTif) {
|
||||
Files.deleteIfExists(path);
|
||||
throw new ValidationException("유효하지 않은 TIF 파일입니다 (GDAL 검증 실패): " + path.getFileName());
|
||||
}
|
||||
// GDAL 검증 (항상 수행)
|
||||
boolean isValidTif = FIleChecker.cmmndGdalInfo(path.toString());
|
||||
if (!isValidTif) {
|
||||
Files.deleteIfExists(path);
|
||||
throw new ValidationException("유효하지 않은 TIF 파일입니다 (GDAL 검증 실패): " + path.getFileName());
|
||||
}
|
||||
|
||||
// TFW 존재/검증
|
||||
if (!Files.exists(tfwPath)) {
|
||||
Files.deleteIfExists(path);
|
||||
@@ -387,7 +396,7 @@ public class MapSheetMngFileCheckerService {
|
||||
"유효하지 않은 TFW 파일입니다 (6줄 숫자 형식 검증 실패): " + tfwPath.getFileName());
|
||||
}
|
||||
saveUploadMeta(path);
|
||||
return skipGdalValidation ? "TIF 업로드 성공(GDAL 검증 스킵)" : "TIF 업로드 성공";
|
||||
return "TIF 업로드 성공";
|
||||
}
|
||||
|
||||
// 기타 확장자: 저장만 하고 메타 기록
|
||||
|
||||
Reference in New Issue
Block a user