dev add cold storage
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-23 14:28:06 +07:00
parent 71aa8ee01a
commit d0b977291c
2 changed files with 33 additions and 25 deletions
@@ -276,17 +276,20 @@ public class ApiController {
private List<SimilarFileDTO> processNonImageFile(FileEntity fileEntity, boolean cloud) throws Exception {
List<SimilarFileDTO> results = new ArrayList<>();
File file = null;
FileEntity duplicateByHash = fileSimilarityService.findDuplicateByHash(fileEntity.getFilePath(),
fileEntity.getMimeType(), fileEntity.getUserId(), cloud);
log.info("duplicateByHash: {}", duplicateByHash);
if (duplicateByHash != null) {
results.add(fileSimilarityService.buildDTO(duplicateByHash));
return results;
}
File file = cloudStorageService.readFileFromStorageByPath(fileEntity.getFilePath());
try {
file = cloudStorageService.readFileFromStorageByPath(fileEntity.getFilePath());
FileProtector.Type type = "document".equals(fileEntity.getMimeType()) ?
FileProtector.Type.DOC : FileProtector.Type.AUDIO;
@@ -314,6 +317,13 @@ public class ApiController {
log.warn("Audio check failed: {}", failed.getMessage());
default -> log.warn("Unexpected result type: {}", checkResult.getClass().getSimpleName());
}
} catch (Exception e) {
throw new Exception("Files for search not valid");
} finally {
if (file != null && file.exists()) {
file.delete();
}
}
return results;
}
@@ -176,8 +176,6 @@ public class CloudStorageService {
s3Client.getObject(objectRequest, tempFile.toPath());
tempFile.deleteOnExit();
return tempFile;
}