@@ -261,7 +261,6 @@ public class ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
|
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
log.error("Error with file extensions : {}", e.getMessage(), e);
|
log.error("Error with file extensions : {}", e.getMessage(), e);
|
||||||
return ResponseEntity.ok().body(new BaseResponse(MessageCode.FILE_FOR_SEARCH_NOT_VALID.getCode(),
|
return ResponseEntity.ok().body(new BaseResponse(MessageCode.FILE_FOR_SEARCH_NOT_VALID.getCode(),
|
||||||
@@ -287,7 +286,7 @@ public class ApiController {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(fileEntity.getFilePath());
|
File 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;
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,9 @@ public class FileSimilarityService {
|
|||||||
List<Long> userIds = new ArrayList<>();
|
List<Long> userIds = new ArrayList<>();
|
||||||
|
|
||||||
if (company != null) {
|
if (company != null) {
|
||||||
userIds.addAll(company.getUsers().stream().map(User::getId).toList());
|
userIds.addAll(company.getUsers().stream()
|
||||||
|
.map(User::getId)
|
||||||
|
.toList());
|
||||||
} else {
|
} else {
|
||||||
userIds.add(userId);
|
userIds.add(userId);
|
||||||
}
|
}
|
||||||
@@ -132,16 +134,10 @@ public class FileSimilarityService {
|
|||||||
List<FileEntity> fileEntityList = fileEntityRepository.findByMimeTypeAndUserIds(mimeType, userIds);
|
List<FileEntity> fileEntityList = fileEntityRepository.findByMimeTypeAndUserIds(mimeType, userIds);
|
||||||
|
|
||||||
for (FileEntity file : fileEntityList) {
|
for (FileEntity file : fileEntityList) {
|
||||||
// if (file.getProtectedFilePath() == null) continue;
|
|
||||||
// File existingFile = cloudStorageService.readFileFromStorageByPath(file.getFilePath());
|
|
||||||
// File newFile = new File(path);
|
|
||||||
|
|
||||||
// if (existingFile.length() == newFile.length()) {
|
|
||||||
if (!file.getStatus().name().equals(FileStatus.TEMP.name()) &&
|
if (!file.getStatus().name().equals(FileStatus.TEMP.name()) &&
|
||||||
calculateFileHash(file.getFilePath(), true).equals(hash)) {
|
calculateFileHash(file.getFilePath(), true).equals(hash)) {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -217,6 +213,7 @@ public class FileSimilarityService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] hashBytes = digest.digest();
|
byte[] hashBytes = digest.digest();
|
||||||
|
|
||||||
return Base64.getEncoder().encodeToString(hashBytes);
|
return Base64.getEncoder().encodeToString(hashBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ public class CloudStorageService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
ResponseBytes<GetObjectResponse> responseBytes = s3Client.getObjectAsBytes(objectRequest);
|
ResponseBytes<GetObjectResponse> responseBytes = s3Client.getObjectAsBytes(objectRequest);
|
||||||
|
|
||||||
return responseBytes.asByteArray();
|
return responseBytes.asByteArray();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to read file from S3: {}", filePath, e);
|
log.error("Failed to read file from S3: {}", filePath, e);
|
||||||
|
|||||||
Reference in New Issue
Block a user