From 93f15720fea5119158b9107a4d2d2a4fea1421dc Mon Sep 17 00:00:00 2001 From: "aditya.chandel" <> Date: Fri, 23 May 2025 23:43:02 -0600 Subject: [PATCH] Fix event handling --- .../booklore/service/LibraryProcessingService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/LibraryProcessingService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/LibraryProcessingService.java index fa2749e26..15fcf4244 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/service/LibraryProcessingService.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/LibraryProcessingService.java @@ -159,8 +159,14 @@ public class LibraryProcessingService { LibraryEntity libraryEntity = libraryRepository.findById(libraryId).orElseThrow(() -> ApiError.LIBRARY_NOT_FOUND.createException(libraryId)); notificationService.sendMessage(Topic.LOG, createLogNotification("Started refreshing library: " + libraryEntity.getName())); detectMovedBooksAndUpdatePaths(libraryEntity); + entityManager.flush(); + entityManager.clear(); deleteRemovedBooks(detectDeletedBookIds(libraryEntity)); + entityManager.flush(); + entityManager.clear(); processLibraryFiles(detectNewBookPaths(libraryEntity)); + entityManager.flush(); + entityManager.clear(); notificationService.sendMessage(Topic.LOG, createLogNotification("Finished refreshing library: " + libraryEntity.getName())); } @@ -207,7 +213,9 @@ public class LibraryProcessingService { protected void deleteRemovedBooks(List bookIds) { bookRepository.deleteByIdIn(bookIds); notificationService.sendMessage(Topic.BOOKS_REMOVE, bookIds); - log.info("Books removed: {}", bookIds); + if (bookIds.size() > 1) { + log.info("Books removed: {}", bookIds); + } } @Transactional