@@ -56,7 +56,7 @@ public interface ImageSimilarityRepository
|
|||||||
JOIN file_entities f
|
JOIN file_entities f
|
||||||
ON f.id = h.file_id
|
ON f.id = h.file_id
|
||||||
WHERE ref.file_id = :fileId AND f.user_id = :userId
|
WHERE ref.file_id = :fileId AND f.user_id = :userId
|
||||||
AND f.status = 'ACTIVE'
|
AND (f.status = 'ACTIVE' OR f.status = 'MODERATION')
|
||||||
""",
|
""",
|
||||||
nativeQuery = true)
|
nativeQuery = true)
|
||||||
List<SimilarImageProjection> findCandidatesFromUserFiles(
|
List<SimilarImageProjection> findCandidatesFromUserFiles(
|
||||||
@@ -82,7 +82,7 @@ public interface ImageSimilarityRepository
|
|||||||
JOIN file_entities f
|
JOIN file_entities f
|
||||||
ON f.id = h.file_id
|
ON f.id = h.file_id
|
||||||
WHERE ref.file_id = :fileId AND f.user_id IN :userIds
|
WHERE ref.file_id = :fileId AND f.user_id IN :userIds
|
||||||
AND f.status = 'ACTIVE'
|
AND (f.status = 'ACTIVE' OR f.status = 'MODERATION')
|
||||||
""",
|
""",
|
||||||
nativeQuery = true)
|
nativeQuery = true)
|
||||||
List<SimilarImageProjection> findCandidatesFromUserFiles(
|
List<SimilarImageProjection> findCandidatesFromUserFiles(
|
||||||
@@ -108,7 +108,7 @@ public interface ImageSimilarityRepository
|
|||||||
JOIN file_entities f ON f.id = h.file_id
|
JOIN file_entities f ON f.id = h.file_id
|
||||||
WHERE h.hash64_hi = :hash64Hi
|
WHERE h.hash64_hi = :hash64Hi
|
||||||
AND h.hash64_lo = :hash64Lo
|
AND h.hash64_lo = :hash64Lo
|
||||||
AND f.status = 'ACTIVE'
|
AND (f.status = 'ACTIVE' OR f.status = 'MODERATION')
|
||||||
""",
|
""",
|
||||||
nativeQuery = true)
|
nativeQuery = true)
|
||||||
List<SimilarImageProjection> findExactDuplicates(
|
List<SimilarImageProjection> findExactDuplicates(
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.vrt.fileprotection.FileProtector;
|
|||||||
import com.vrt.fileprotection.NoCopyCheckResult;
|
import com.vrt.fileprotection.NoCopyCheckResult;
|
||||||
import com.vrt.fileprotection.audio.AudioCheckResult;
|
import com.vrt.fileprotection.audio.AudioCheckResult;
|
||||||
import com.vrt.fileprotection.documents.DocumentCheckResult;
|
import com.vrt.fileprotection.documents.DocumentCheckResult;
|
||||||
import com.vrt.fileprotection.image.ImageCheckResult;
|
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -403,6 +402,7 @@ public class FileUploadServiceImpl implements FileUploadService {
|
|||||||
|
|
||||||
FileProtector.Type type = "document".equals(session.getFileType()) ?
|
FileProtector.Type type = "document".equals(session.getFileType()) ?
|
||||||
FileProtector.Type.DOC : FileProtector.Type.valueOf(session.getFileType().toUpperCase());
|
FileProtector.Type.DOC : FileProtector.Type.valueOf(session.getFileType().toUpperCase());
|
||||||
|
|
||||||
NoCopyCheckResult checkResult = noCopyFileService.checkFile(file, type);
|
NoCopyCheckResult checkResult = noCopyFileService.checkFile(file, type);
|
||||||
|
|
||||||
switch (checkResult) {
|
switch (checkResult) {
|
||||||
@@ -411,13 +411,11 @@ public class FileUploadServiceImpl implements FileUploadService {
|
|||||||
throw new DuplicateImageException("Duplicate", info.getId(),
|
throw new DuplicateImageException("Duplicate", info.getId(),
|
||||||
Long.valueOf(info.getOwnerId()));
|
Long.valueOf(info.getOwnerId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
case AudioCheckResult.Success success -> {
|
case AudioCheckResult.Success success -> {
|
||||||
FileProtector.FileInfo info = success.getInfo();
|
FileProtector.FileInfo info = success.getInfo();
|
||||||
throw new DuplicateImageException("Duplicate", info.getId(),
|
throw new DuplicateImageException("Duplicate", info.getId(),
|
||||||
Long.valueOf(info.getOwnerId()));
|
Long.valueOf(info.getOwnerId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
case DocumentCheckResult.Failed failed ->
|
case DocumentCheckResult.Failed failed ->
|
||||||
log.warn("Document check failed: {}", failed.getMessage());
|
log.warn("Document check failed: {}", failed.getMessage());
|
||||||
case AudioCheckResult.Failed failed ->
|
case AudioCheckResult.Failed failed ->
|
||||||
@@ -580,8 +578,8 @@ public class FileUploadServiceImpl implements FileUploadService {
|
|||||||
Path path = Paths.get(filePath);
|
Path path = Paths.get(filePath);
|
||||||
Map<String, Long> hash = imageHashService.calculateHash(path);
|
Map<String, Long> hash = imageHashService.calculateHash(path);
|
||||||
|
|
||||||
List<SimilarImageProjection> duplicates = fileSimilarityService.findDuplicatedByHash(hash.get("hi"),
|
List<SimilarImageProjection> duplicates = fileSimilarityService.findDuplicatedByHash(
|
||||||
hash.get("low"));
|
hash.get("hi"), hash.get("low"));
|
||||||
|
|
||||||
if (!duplicates.isEmpty()) {
|
if (!duplicates.isEmpty()) {
|
||||||
throw new DuplicateImageException("Duplicate", duplicates.getFirst().getId(),
|
throw new DuplicateImageException("Duplicate", duplicates.getFirst().getId(),
|
||||||
|
|||||||
Reference in New Issue
Block a user