dev change key
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-04-07 12:57:30 +07:00
parent b71ba527d2
commit 8f2127bed5
@@ -5,6 +5,7 @@ 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;
@@ -382,9 +383,9 @@ public class FileUploadServiceImpl implements FileUploadService {
String finalFilePath = assembleFileSynchronously(session); String finalFilePath = assembleFileSynchronously(session);
if (findSimilar == 0) { if (findSimilar == 0) {
if (session.getFileType().startsWith("image")) { // if (session.getFileType().startsWith("image")) {
checkForDuplicatesSynchronously(finalFilePath); // checkForDuplicatesSynchronously(finalFilePath);
} else if (session.getFileType().startsWith("audio") || session.getFileType().startsWith("document")) { // } else if (session.getFileType().startsWith("audio") || session.getFileType().startsWith("document")) {
fileSimilarityService.hasDuplicatesByHash(finalFilePath ,session.getFileType(), fileSimilarityService.hasDuplicatesByHash(finalFilePath ,session.getFileType(),
session.getUserId()); session.getUserId());
@@ -399,9 +400,12 @@ public class FileUploadServiceImpl implements FileUploadService {
throw new FileFormatException("Failed to upload chunk: .wav file not have RIFF header or " + throw new FileFormatException("Failed to upload chunk: .wav file not have RIFF header or " +
"another problems with .wav file"); "another problems with .wav file");
} }
FileProtector.Type type = FileProtector.Type.IMAGE;
FileProtector.Type type = "document".equals(session.getFileType()) ? if (session.getFileType().startsWith("audio")) type = FileProtector.Type.AUDIO;
FileProtector.Type.DOC : FileProtector.Type.valueOf(session.getFileType().toUpperCase()); if (session.getFileType().startsWith("document")) type = FileProtector.Type.DOC;
// FileProtector.Type type = "document".equals(session.getFileType()) ?
// FileProtector.Type.DOC : FileProtector.Type.valueOf(session.getFileType().toUpperCase());
NoCopyCheckResult checkResult = noCopyFileService.checkFile(file, type); NoCopyCheckResult checkResult = noCopyFileService.checkFile(file, type);
@@ -411,18 +415,26 @@ 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 ImageCheckResult.Success success -> {
FileProtector.FileInfo info = success.getInfo();
throw new DuplicateImageException("Duplicate", info.getId(),
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 ->
log.warn("Audio check failed: {}", failed.getMessage()); log.warn("Audio check failed: {}", failed.getMessage());
default -> log.warn("Unexpected result type: {}", checkResult.getClass().getSimpleName()); default -> log.warn("Unexpected result type: {}", checkResult.getClass().getSimpleName());
} }
} // }
} }
session.setStatus(UploadStatus.COMPLETED); session.setStatus(UploadStatus.COMPLETED);