Fix:Remove collections when removing library

This commit is contained in:
advplyr 2022-11-11 17:44:19 -06:00
parent 6f901defd6
commit 28feed6ea2
6 changed files with 55 additions and 38 deletions

View file

@ -131,6 +131,13 @@ class LibraryController {
// Remove library watcher
this.watcher.removeLibrary(library)
// Remove collections for library
var collections = this.db.collections.filter(c => c.libraryId === library.id)
for (const collection of collections) {
Logger.info(`[Server] deleting collection "${collection.name}" for library "${library.name}"`)
await this.db.removeEntity('collection', collection.id)
}
// Remove items in this library
var libraryItems = this.db.libraryItems.filter(li => li.libraryId === library.id)
Logger.info(`[Server] deleting library "${library.name}" with ${libraryItems.length} items"`)