@@ -276,17 +276,20 @@ public class ApiController {
|
|||||||
|
|
||||||
private List<SimilarFileDTO> processNonImageFile(FileEntity fileEntity, boolean cloud) throws Exception {
|
private List<SimilarFileDTO> processNonImageFile(FileEntity fileEntity, boolean cloud) throws Exception {
|
||||||
List<SimilarFileDTO> results = new ArrayList<>();
|
List<SimilarFileDTO> results = new ArrayList<>();
|
||||||
|
File file = null;
|
||||||
FileEntity duplicateByHash = fileSimilarityService.findDuplicateByHash(fileEntity.getFilePath(),
|
FileEntity duplicateByHash = fileSimilarityService.findDuplicateByHash(fileEntity.getFilePath(),
|
||||||
fileEntity.getMimeType(), fileEntity.getUserId(), cloud);
|
fileEntity.getMimeType(), fileEntity.getUserId(), cloud);
|
||||||
|
|
||||||
log.info("duplicateByHash: {}", duplicateByHash);
|
log.info("duplicateByHash: {}", duplicateByHash);
|
||||||
|
|
||||||
if (duplicateByHash != null) {
|
if (duplicateByHash != null) {
|
||||||
results.add(fileSimilarityService.buildDTO(duplicateByHash));
|
results.add(fileSimilarityService.buildDTO(duplicateByHash));
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = cloudStorageService.readFileFromStorageByPath(fileEntity.getFilePath());
|
try {
|
||||||
|
file = cloudStorageService.readFileFromStorageByPath(fileEntity.getFilePath());
|
||||||
FileProtector.Type type = "document".equals(fileEntity.getMimeType()) ?
|
FileProtector.Type type = "document".equals(fileEntity.getMimeType()) ?
|
||||||
FileProtector.Type.DOC : FileProtector.Type.AUDIO;
|
FileProtector.Type.DOC : FileProtector.Type.AUDIO;
|
||||||
|
|
||||||
@@ -314,6 +317,13 @@ public class ApiController {
|
|||||||
log.warn("Audio check failed: {}", failed.getMessage());
|
log.warn("Audio check failed: {}", failed.getMessage());
|
||||||
default -> log.warn("Unexpected result type: {}", checkResult.getClass().getSimpleName());
|
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;
|
return results;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,8 +176,6 @@ public class CloudStorageService {
|
|||||||
|
|
||||||
s3Client.getObject(objectRequest, tempFile.toPath());
|
s3Client.getObject(objectRequest, tempFile.toPath());
|
||||||
|
|
||||||
tempFile.deleteOnExit();
|
|
||||||
|
|
||||||
return tempFile;
|
return tempFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user