Fix 'Lock wait timeout exceeded exception' during library re-scan
This commit is contained in:
committed by
Aditya Chandel
parent
841e359b92
commit
8edf589f3d
@@ -42,6 +42,11 @@ export class AppComponent implements OnInit {
|
||||
this.bookService.handleBookUpdate(JSON.parse(message.body));
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/book-metadata-batch-update').subscribe((message: Message) => {
|
||||
const updatedBooks = JSON.parse(message.body);
|
||||
this.bookService.handleMultipleBookUpdates(updatedBooks);
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/log').subscribe((message: Message) => {
|
||||
const logNotification = parseLogNotification(message.body);
|
||||
this.eventService.handleIncomingLog(logNotification);
|
||||
|
||||
@@ -426,6 +426,19 @@ export class BookService {
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks});
|
||||
}
|
||||
|
||||
handleMultipleBookUpdates(updatedBooks: Book[]): void {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentBooks = currentState.books || [];
|
||||
|
||||
const updatedMap = new Map(updatedBooks.map(book => [book.id, book]));
|
||||
|
||||
const mergedBooks = currentBooks.map(book =>
|
||||
updatedMap.has(book.id) ? updatedMap.get(book.id)! : book
|
||||
);
|
||||
|
||||
this.bookStateSubject.next({ ...currentState, books: mergedBooks });
|
||||
}
|
||||
|
||||
handleBookMetadataUpdate(bookId: number, updatedMetadata: BookMetadata) {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
|
||||
Reference in New Issue
Block a user