Enable rescan library

This commit is contained in:
aditya.chandel
2025-02-08 06:48:19 -07:00
parent 25e2147aa0
commit f540679af9
3 changed files with 12 additions and 12 deletions
@@ -54,9 +54,9 @@ public class LibraryController {
return ResponseEntity.ok(books);
}
/*@PutMapping("/{libraryId}/refresh")
@PutMapping("/{libraryId}/refresh")
public ResponseEntity<?> refreshLibrary(@PathVariable long libraryId) {
libraryService.refreshLibrary(libraryId);
return ResponseEntity.noContent().build();
}*/
}
}
@@ -101,14 +101,14 @@ public class LibraryProcessingService {
}
}
/*@Transactional
@Transactional
public void refreshLibrary(long libraryId) throws IOException {
LibraryEntity libraryEntity = libraryRepository.findById(libraryId).orElseThrow(() -> ApiError.LIBRARY_NOT_FOUND.createException(libraryId));
notificationService.sendMessage(Topic.LOG, createLogNotification("Started refreshing library: " + libraryEntity.getName()));
processLibraryFiles(getUnProcessedFiles(libraryEntity));
deleteRemovedBooks(getRemovedBooks(libraryEntity));
notificationService.sendMessage(Topic.LOG, createLogNotification("Finished refreshing library: " + libraryEntity.getName()));
}*/
}
@Transactional
protected void deleteRemovedBooks(List<BookEntity> removedBookEntities) {
@@ -143,7 +143,7 @@ public class LibraryProcessingService {
return null;
}
/*@Transactional
@Transactional
protected List<BookEntity> getRemovedBooks(LibraryEntity libraryEntity) throws IOException {
List<LibraryFile> libraryFiles = getLibraryFiles(libraryEntity);
List<BookEntity> bookEntities = libraryEntity.getBookEntities();
@@ -151,21 +151,21 @@ public class LibraryProcessingService {
.map(LibraryFile::getFileName)
.collect(Collectors.toSet());
return bookEntities.stream()
.filter(book -> !libraryFilePaths.contains(book.getPath()))
.filter(book -> !libraryFilePaths.contains(book.getFileName()))
.collect(Collectors.toList());
}*/
}
/*@Transactional
@Transactional
protected List<LibraryFile> getUnProcessedFiles(LibraryEntity libraryEntity) throws IOException {
List<LibraryFile> libraryFiles = getLibraryFiles(libraryEntity);
List<BookEntity> bookEntities = libraryEntity.getBookEntities();
Set<String> processedPaths = bookEntities.stream()
.map(BookEntity::getPath)
.map(BookEntity::getFileName)
.collect(Collectors.toSet());
return libraryFiles.stream()
.filter(libraryFile -> !processedPaths.contains(libraryFile.getFileName()))
.collect(Collectors.toList());
}*/
}
private List<LibraryFile> getLibraryFiles(LibraryEntity libraryEntity) throws IOException {
List<LibraryFile> libraryFiles = new ArrayList<>();
@@ -170,7 +170,7 @@ public class LibraryService {
return libraryMapper.toLibrary(libraryEntity);
}
/*public void refreshLibrary(long libraryId) {
public void refreshLibrary(long libraryId) {
libraryRepository.findById(libraryId).orElseThrow(() -> ApiError.LIBRARY_NOT_FOUND.createException(libraryId));
Thread.startVirtualThread(() -> {
try {
@@ -182,7 +182,7 @@ public class LibraryService {
}
log.info("Parsing task completed!");
});
}*/
}
public Library getLibrary(long libraryId) {
LibraryEntity libraryEntity = libraryRepository.findById(libraryId).orElseThrow(() -> ApiError.LIBRARY_NOT_FOUND.createException(libraryId));