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

This commit is contained in:
vladp
2026-04-15 12:49:03 +07:00
parent 484475eadc
commit 064a888188
2 changed files with 21 additions and 11 deletions
@@ -240,10 +240,13 @@ public class FileUploadServiceImpl implements FileUploadService {
.fileExtension(session.getExtension())
.checksum(checksum)
.uploadSessionId(session.getUploadId())
.protectionStatus(ProtectionStatus.PROCESSING)
.status(status)
.build();
if (status != FileStatus.TEMP) {
fileEntity.setProtectionStatus(ProtectionStatus.PROCESSING);
}
FileEntity saved = fileEntityRepository.save(fileEntity);
if (session.getFileType().equals("image") && status != FileStatus.PRIVATE) {
@@ -65,6 +65,7 @@ public class MonitoringSearchService {
MonitoringType monitoringType = monitoring.getMonitoringType();
TariffDTO tariffMonitoring = tariffService.getTariffByType(TariffType.valueOf(monitoringType.name()));
User user = userRepository.findById(monitoring.getUserId()).orElseThrow();
try {
tariffInfoService.writeOffTokens(monitoring.getUserId(), tariffMonitoring.getTokens(), OperationType.MONITORING);
@@ -89,10 +90,14 @@ public class MonitoringSearchService {
allResults.addAll(yandexImages);
log.info("Yandex search found {} results", yandexImages.size());
} catch (TimeoutException e) {
log.warn("Yandex search timeout for monitoring file {}", monitoring.getFile().getId());
} catch (IOException e) {
log.error("Yandex search failed for monitoring file {}", monitoring.getFile().getId(), e);
} catch (TimeoutException | IOException e) {
log.error("Error processing monitoring search", e);
monitoring.setLastRunStatus("ERROR: " + e.getMessage());
updateNextRun(monitoring);
monitoringRepository.save(monitoring);
notificationService.addNotification(NotificationType.SEARCH_OPERATION_FAILED, user.getId());
}
} else {
log.info("Yandex search is disabled by settings");
@@ -109,10 +114,14 @@ public class MonitoringSearchService {
allResults.addAll(googleImages);
log.info("Google search found {} results", googleImages.size());
} catch (TimeoutException e) {
log.warn("Google search timeout for monitoring file {}", monitoring.getFile().getId());
} catch (IOException e) {
log.error("Google search failed for monitoring file {}", monitoring.getFile().getId(), e);
} catch (TimeoutException | IOException e) {
log.error("Error processing monitoring search", e);
monitoring.setLastRunStatus("ERROR: " + e.getMessage());
updateNextRun(monitoring);
monitoringRepository.save(monitoring);
notificationService.addNotification(NotificationType.SEARCH_OPERATION_FAILED, user.getId());
}
} else {
log.info("Google search is disabled by settings");
@@ -139,7 +148,6 @@ public class MonitoringSearchService {
}
} catch (TariffNotFoundException e) {
User user = userRepository.findById(monitoring.getUserId()).orElseThrow();
TariffInfo activeTariffInfo = user.getActiveTariffInfo();
int currentTokens = activeTariffInfo.getTokens() + activeTariffInfo.getBoughtTokens();
@@ -154,7 +162,6 @@ public class MonitoringSearchService {
notificationService.addNotification(NotificationType.TOKEN_NOT_FOUND, user.getId(),
NotificationMessage.FILE_SEARCH.getMessageKey());
} catch (Exception e) {
User user = userRepository.findById(monitoring.getUserId()).orElseThrow();
log.error("Error processing monitoring search", e);
monitoring.setLastRunStatus("ERROR: " + e.getMessage());
updateNextRun(monitoring);