This commit is contained in:
@@ -133,11 +133,11 @@ public class FileSimilarityService {
|
||||
|
||||
for (FileEntity file : fileEntityList) {
|
||||
if (file.getProtectedFilePath() == null) continue;
|
||||
File existingFile = new File(file.getProtectedFilePath());
|
||||
File existingFile = cloudStorageService.readFileFromStorageByPath(file.getFilePath());
|
||||
File newFile = new File(path);
|
||||
|
||||
if (existingFile.length() == newFile.length()) {
|
||||
if (calculateFileHash(file.getProtectedFilePath()).equals(hash)) {
|
||||
if (calculateFileHash(file.getFilePath()).equals(hash)) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
@@ -201,9 +201,8 @@ public class FileSimilarityService {
|
||||
|
||||
private String calculateFileHash(String path) throws Exception {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
File file = cloudStorageService.readFileFromStorageByPath(path);
|
||||
|
||||
try (InputStream is = new FileInputStream(file)) {
|
||||
try (InputStream is = cloudStorageService.readFileFromStorage(path)) {
|
||||
byte[] buffer = new byte[8192];
|
||||
int read;
|
||||
while ((read = is.read(buffer)) > 0) {
|
||||
|
||||
@@ -387,8 +387,8 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
if (session.getFileType().startsWith("image")) {
|
||||
checkForDuplicatesSynchronously(finalFilePath);
|
||||
} else if (session.getFileType().startsWith("audio") || session.getFileType().startsWith("document")) {
|
||||
// fileSimilarityService.hasDuplicatesByHash(finalFilePath ,session.getFileType(),
|
||||
// session.getUserId());
|
||||
fileSimilarityService.hasDuplicatesByHash(finalFilePath ,session.getFileType(),
|
||||
session.getUserId());
|
||||
|
||||
File file = new File(finalFilePath);
|
||||
// File file = cloudStorageService.readFileFromStorageByPath(finalFilePath);
|
||||
|
||||
Reference in New Issue
Block a user