@@ -6,6 +6,7 @@ import com.vrt.fileprotection.NoCopyCheckResult;
|
||||
import com.vrt.fileprotection.audio.AudioCheckResult;
|
||||
import com.vrt.fileprotection.documents.DocumentCheckResult;
|
||||
import com.vrt.fileprotection.image.ImageCheckResult;
|
||||
import com.vrt.fileprotection.image.ImageLocalSearch;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -319,15 +320,11 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
String finalFilePath = assembleFileSynchronously(session);
|
||||
|
||||
if (findSimilar == 0) {
|
||||
// if (session.getFileType().startsWith("image")) {
|
||||
// checkForDuplicatesSynchronously(finalFilePath);
|
||||
// } else if (session.getFileType().startsWith("audio") || session.getFileType().startsWith("document")) {
|
||||
if (session.getFileType().startsWith("image")) {
|
||||
checkForDuplicatesSynchronously(finalFilePath);
|
||||
} else {
|
||||
} else if (session.getFileType().startsWith("audio") || session.getFileType().startsWith("document")) {
|
||||
fileSimilarityService.hasDuplicatesByHash(finalFilePath, session.getUserId(),
|
||||
session.getFileType());
|
||||
}
|
||||
|
||||
File file = new File(finalFilePath);
|
||||
FileProtector.Type type = "document".equals(session.getFileType()) ?
|
||||
@@ -341,11 +338,6 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
throw new DuplicateImageException("Duplicate", info.getId(),
|
||||
Long.valueOf(info.getOwnerId()));
|
||||
}
|
||||
case ImageCheckResult.Success success -> {
|
||||
FileProtector.FileInfo info = success.getInfo();
|
||||
throw new DuplicateImageException("Duplicate", info.getId(),
|
||||
Long.valueOf(info.getOwnerId()));
|
||||
}
|
||||
case AudioCheckResult.Success success -> {
|
||||
FileProtector.FileInfo info = success.getInfo();
|
||||
throw new DuplicateImageException("Duplicate", info.getId(),
|
||||
@@ -355,11 +347,9 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
log.warn("Document check failed: {}", failed.getMessage());
|
||||
case AudioCheckResult.Failed failed ->
|
||||
log.warn("Audio check failed: {}", failed.getMessage());
|
||||
case ImageCheckResult.Failed failed ->
|
||||
log.warn("ImageCheckResult check failed: {}", failed.getMessage());
|
||||
default -> log.warn("Unexpected result type: {}", checkResult.getClass().getSimpleName());
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
session.setStatus(UploadStatus.COMPLETED);
|
||||
|
||||
@@ -44,8 +44,7 @@ public class ImageLocalSearchImpl implements ImageLocalSearch {
|
||||
@Override
|
||||
public @Nullable FileProtector.FileInfo findByPHash(@NotNull PHash pHash) {
|
||||
ImageHashEntity imageHashEntity =
|
||||
imageHashRepository.findByHash64HiAndHash64Lo(pHash.getFirstPart(),
|
||||
pHash.getSecondPart());
|
||||
imageHashRepository.findByHash64HiAndHash64Lo(pHash.getFirstPart(), pHash.getSecondPart());
|
||||
|
||||
if (imageHashEntity == null) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user