Fix scheduled library rescan failing due to missing authentication

This commit is contained in:
aditya.chandel
2025-07-21 18:42:27 -06:00
committed by Aditya Chandel
parent c96997c2d8
commit 4fe00e3bce
2 changed files with 6 additions and 1 deletions
@@ -190,6 +190,11 @@ public class LibraryService {
return libraryMapper.toLibrary(libraryEntity);
}
public List<Library> getAllLibraries() {
List<LibraryEntity> libraries = libraryRepository.findAll();
return libraries.stream().map(libraryMapper::toLibrary).toList();
}
public List<Library> getLibraries() {
BookLoreUser user = authenticationService.getAuthenticatedUser();
BookLoreUserEntity userEntity = userRepository.findById(user.getId()).orElseThrow(() -> new UsernameNotFoundException("User not found"));
@@ -17,7 +17,7 @@ public class LibraryRescanScheduler {
@Scheduled(cron = "0 0 0 * * *") // At 00:00 every day
public void rescanLibraries() {
log.info("Starting scheduled library rescan at midnight");
for (Library library : libraryService.getLibraries()) {
for (Library library : libraryService.getAllLibraries()) {
try {
libraryService.rescanLibrary(library.getId());
log.info("Rescanned library '{}'", library.getName());