This commit is contained in:
@@ -494,15 +494,15 @@ public class ApiController {
|
|||||||
errorData));
|
errorData));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entityResponse.isExistsOnDisk()) {
|
// if (!entityResponse.isExistsOnDisk()) {
|
||||||
Map<String, Object> errorData = new HashMap<>();
|
// Map<String, Object> errorData = new HashMap<>();
|
||||||
errorData.put("onDisk", entityResponse.isExistsOnDisk());
|
// errorData.put("onDisk", entityResponse.isExistsOnDisk());
|
||||||
|
//
|
||||||
return ResponseEntity.ok().body(new BaseResponse(20004,
|
// return ResponseEntity.ok().body(new BaseResponse(20004,
|
||||||
MessageCode.FILE_NOT_EXIST.getCode(),
|
// MessageCode.FILE_NOT_EXIST.getCode(),
|
||||||
MessageCode.FILE_NOT_EXIST.getDescription(),
|
// MessageCode.FILE_NOT_EXIST.getDescription(),
|
||||||
errorData));
|
// errorData));
|
||||||
}
|
// }
|
||||||
|
|
||||||
File file = cloudStorageService.readFileFromStorageByPath(entityResponse.getProtectedFilePath());
|
File file = cloudStorageService.readFileFromStorageByPath(entityResponse.getProtectedFilePath());
|
||||||
|
|
||||||
|
|||||||
@@ -323,14 +323,14 @@ public class FileEntityService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkFileExistsOnDisk(String filePath) {
|
// private boolean checkFileExistsOnDisk(String filePath) {
|
||||||
try {
|
// try {
|
||||||
return Files.exists(Paths.get(filePath));
|
// return Files.exists(Paths.get(filePath));
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
log.warn("Error checking file existence: {}", filePath, e);
|
// log.warn("Error checking file existence: {}", filePath, e);
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private String determineFileExtension(String fileExt, FileEntity fileEntity) {
|
private String determineFileExtension(String fileExt, FileEntity fileEntity) {
|
||||||
if (fileExt != null) {
|
if (fileExt != null) {
|
||||||
@@ -343,7 +343,7 @@ public class FileEntityService {
|
|||||||
private final FileMonitoringRepository fileMonitoringRepository;
|
private final FileMonitoringRepository fileMonitoringRepository;
|
||||||
|
|
||||||
private FileEntityResponse convertToResponse(FileEntity fileEntity, int version) {
|
private FileEntityResponse convertToResponse(FileEntity fileEntity, int version) {
|
||||||
boolean existsOnDisk = checkFileExistsOnDisk(fileEntity.getFilePath());
|
// boolean existsOnDisk = checkFileExistsOnDisk(fileEntity.getFilePath());
|
||||||
User user = userRepository.findById(fileEntity.getUserId()).get();
|
User user = userRepository.findById(fileEntity.getUserId()).get();
|
||||||
String fileName = fileEntity.getOriginalFileName();
|
String fileName = fileEntity.getOriginalFileName();
|
||||||
String name = fileName;
|
String name = fileName;
|
||||||
@@ -375,7 +375,7 @@ public class FileEntityService {
|
|||||||
.updatedAt(fileEntity.getUpdatedAt())
|
.updatedAt(fileEntity.getUpdatedAt())
|
||||||
.formattedSize(formatFileSize(fileEntity.getFileSize()))
|
.formattedSize(formatFileSize(fileEntity.getFileSize()))
|
||||||
.downloadUrl("/api/v" + version + "/files/download/" + fileEntity.getId())
|
.downloadUrl("/api/v" + version + "/files/download/" + fileEntity.getId())
|
||||||
.existsOnDisk(existsOnDisk)
|
// .existsOnDisk(existsOnDisk)
|
||||||
.supportId(fileEntity.getSupportId())
|
.supportId(fileEntity.getSupportId())
|
||||||
.protectStatus(fileEntity.getProtectionStatus().toString())
|
.protectStatus(fileEntity.getProtectionStatus().toString())
|
||||||
.fileName(name + "_nocopy_protected" + "." + fileEntity.getFileExtension())
|
.fileName(name + "_nocopy_protected" + "." + fileEntity.getFileExtension())
|
||||||
|
|||||||
Reference in New Issue
Block a user