dev test baseurl for test
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-21 11:01:15 +07:00
parent c33ffe516a
commit 1dd6a6b7e2
@@ -117,7 +117,7 @@ public class FileSimilarityService {
}
public FileEntity findDuplicateByHash(String path, String mimeType, Long userId) throws Exception {
String hash = calculateFileHash(path);
String hash = calculateFileHash(path, false);
User user = userRepository.findById(userId).orElseThrow();
Company company = user.getCompany();
@@ -132,15 +132,15 @@ public class FileSimilarityService {
List<FileEntity> fileEntityList = fileEntityRepository.findByMimeTypeAndUserIds(mimeType, userIds);
for (FileEntity file : fileEntityList) {
if (file.getProtectedFilePath() == null) continue;
File existingFile = cloudStorageService.readFileFromStorageByPath(file.getFilePath());
File newFile = new File(path);
// if (file.getProtectedFilePath() == null) continue;
// File existingFile = cloudStorageService.readFileFromStorageByPath(file.getFilePath());
// File newFile = new File(path);
if (existingFile.length() == newFile.length()) {
if (calculateFileHash(file.getFilePath()).equals(hash)) {
// if (existingFile.length() == newFile.length()) {
if (calculateFileHash(file.getFilePath(), true).equals(hash)) {
return file;
}
}
// }
}
return null;
@@ -199,10 +199,12 @@ public class FileSimilarityService {
}
private String calculateFileHash(String path) throws Exception {
private String calculateFileHash(String path, boolean cloud) throws Exception {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
try (InputStream is = cloudStorageService.readFileFromStorage(path)) {
File file = cloud ? cloudStorageService.readFileFromStorageByPath(path): new File(path);
try (InputStream is = new FileInputStream(file)) {
byte[] buffer = new byte[8192];
int read;
while ((read = is.read(buffer)) > 0) {