fix(library-processing): re-fetch library entity after clearing entity manager during rescan (#2507)

* fix(library-processing): re-fetch library entity after clearing entity manager during rescan

Ensure the latest library entity state is retrieved after clearing the entity manager in rescanLibrary. Add test to verify fresh entity is used for subsequent processing.

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* test(library-processing): update rescan test to verify grouping service usage and remove obsolete assertions

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

---------

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
This commit is contained in:
Balázs Szücs
2026-01-27 16:38:30 -07:00
committed by GitHub
parent 257c016f3f
commit 878bc44138
2 changed files with 61 additions and 5 deletions
@@ -98,6 +98,9 @@ public class LibraryProcessingService {
}
bookRestorationService.restoreDeletedBooks(libraryFiles);
entityManager.clear();
// Re-fetch library entity to get fresh state after entity manager was cleared
libraryEntity = libraryRepository.findById(context.getLibraryId())
.orElseThrow(() -> ApiError.LIBRARY_NOT_FOUND.createException(context.getLibraryId()));
List<LibraryFile> newFiles = detectNewBookPaths(libraryFiles, libraryEntity);