NCBACK-25 add protection for audio and use hash method from library
Test Workflow / test (push) Successful in 2s

This commit is contained in:
vladp
2026-01-23 13:22:02 +07:00
parent e37cc06cd0
commit 51654fd060
12 changed files with 99 additions and 40 deletions
@@ -22,19 +22,19 @@ public class ImageHashService {
private final ImageHashRepository repository;
public Map<String, Integer> calculateHash(Path imagePath) throws IOException {
public Map<String, Long> calculateHash(Path imagePath) throws IOException {
File file = imagePath.toFile();
PHash pHash = PerceptualHashHelper.INSTANCE.generateDCTPerceptualHash(file);
Long firstPart = pHash.getFirstPart();
Long secondPart = pHash.getSecondPart();
Map<String, Integer> hash = Map.of(
"hi", Math.toIntExact(firstPart),
"low", Math.toIntExact(secondPart));
Map<String, Long> hash = Map.of(
"hi", firstPart,
"low", secondPart);
return hash;
}
public void create(FileEntity file, Map<String, Integer> stringIntegerMap) {
public void create(FileEntity file, Map<String, Long> stringIntegerMap) {
ImageHashEntity entity = ImageHashEntity.builder()
.file(file)
.hash64Hi(stringIntegerMap.get("hi"))