NCBACK-34 fix send exception
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-01-19 15:49:27 +07:00
parent e979712b7c
commit 0c0fadf5ec
10 changed files with 206 additions and 120 deletions
@@ -16,6 +16,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Map;
@Service
@RequiredArgsConstructor
@@ -24,25 +25,24 @@ public class ImageHashService {
private final ImageHashRepository repository;
public void create(FileEntity file, Path imagePath) {
try {
long hash64 = computePhash64(imagePath);
public Map<String, Integer> calculateHash(Path imagePath) throws IOException {
long hash64 = computePhash64(imagePath);
int hi = high32(hash64);
int lo = low32(hash64);
return Map.of(
"hi", high32(hash64),
"low", low32(hash64));
}
ImageHashEntity entity = ImageHashEntity.builder()
.file(file)
.hash64Hi(hi)
.hash64Lo(lo)
.hashAlgorithm("PHASH64")
.createdAt(LocalDateTime.now())
.build();
public void create(FileEntity file, Map<String, Integer> stringIntegerMap) {
ImageHashEntity entity = ImageHashEntity.builder()
.file(file)
.hash64Hi(stringIntegerMap.get("hi"))
.hash64Lo(stringIntegerMap.get("low"))
.hashAlgorithm("PHASH64")
.createdAt(LocalDateTime.now())
.build();
repository.save(entity);
} catch (IOException e) {
throw new RuntimeException("Failed to compute image hash", e);
}
repository.save(entity);
}
private long computePhash64(Path path) throws IOException {