NCBACK-34 add logic to find similar image in db
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-01-13 22:40:52 +07:00
parent 344ec075d4
commit 8ac73ff045
18 changed files with 394 additions and 188 deletions
@@ -402,7 +402,7 @@ public class FileUploadServiceImpl implements FileUploadService {
session.getUploadId(), session.getFileName());
Path finalFilePath = null;
String checksum = null;
String checksum;
try {
finalFilePath = prepareFinalFile(session);
@@ -591,44 +591,10 @@ public class FileUploadServiceImpl implements FileUploadService {
private void handleAssemblyFailure(FileUploadSession session, Exception e) {
session.setStatus(UploadStatus.FAILED);
session.setLastError(e.getMessage());
sessionRepository.save(session);
log.error("File assembly failed for session {}: {}",
session.getUploadId(), e.getMessage());
}
// @Override
// @Transactional
// public void cleanupExpiredSessions() {
// log.info("Starting cleanup of expired upload sessions");
//
// LocalDateTime expiryThreshold = LocalDateTime.now().minusHours(sessionExpiryHours);
//
// try {
// var expiredSessions = sessionRepository.findByStatusInAndCreatedAtBefore(
// Set.of(UploadStatus.INITIATED, UploadStatus.UPLOADING, UploadStatus.FAILED),
// expiryThreshold
// );
//
// int cleanedCount = 0;
// for (FileUploadSession session : expiredSessions) {
// session.setStatus(UploadStatus.FAILED);
// session.setLastError("Session expired during cleanup");
// sessionRepository.save(session);
//
// CompletableFuture.runAsync(() -> cleanupSessionFiles(session));
// cleanedCount++;
// }
//
// log.info("Cleaned up {} expired upload sessions", cleanedCount);
//
// } catch (Exception e) {
// log.error("Error during session cleanup", e);
// }
// }
private Path getChunkDirectory(Long userId, String uploadId) {
return storageRoot.resolve("temp")
.resolve("user")