Fix scheduled library rescan failing due to missing authentication
This commit is contained in:
committed by
Aditya Chandel
parent
c96997c2d8
commit
4fe00e3bce
+5
@@ -190,6 +190,11 @@ public class LibraryService {
|
|||||||
return libraryMapper.toLibrary(libraryEntity);
|
return libraryMapper.toLibrary(libraryEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Library> getAllLibraries() {
|
||||||
|
List<LibraryEntity> libraries = libraryRepository.findAll();
|
||||||
|
return libraries.stream().map(libraryMapper::toLibrary).toList();
|
||||||
|
}
|
||||||
|
|
||||||
public List<Library> getLibraries() {
|
public List<Library> getLibraries() {
|
||||||
BookLoreUser user = authenticationService.getAuthenticatedUser();
|
BookLoreUser user = authenticationService.getAuthenticatedUser();
|
||||||
BookLoreUserEntity userEntity = userRepository.findById(user.getId()).orElseThrow(() -> new UsernameNotFoundException("User not found"));
|
BookLoreUserEntity userEntity = userRepository.findById(user.getId()).orElseThrow(() -> new UsernameNotFoundException("User not found"));
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ public class LibraryRescanScheduler {
|
|||||||
@Scheduled(cron = "0 0 0 * * *") // At 00:00 every day
|
@Scheduled(cron = "0 0 0 * * *") // At 00:00 every day
|
||||||
public void rescanLibraries() {
|
public void rescanLibraries() {
|
||||||
log.info("Starting scheduled library rescan at midnight");
|
log.info("Starting scheduled library rescan at midnight");
|
||||||
for (Library library : libraryService.getLibraries()) {
|
for (Library library : libraryService.getAllLibraries()) {
|
||||||
try {
|
try {
|
||||||
libraryService.rescanLibrary(library.getId());
|
libraryService.rescanLibrary(library.getId());
|
||||||
log.info("Rescanned library '{}'", library.getName());
|
log.info("Rescanned library '{}'", library.getName());
|
||||||
|
|||||||
Reference in New Issue
Block a user