mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-04-18 13:09:43 +00:00
Fix item_removed payload to include libraryId
This commit is contained in:
parent
c4c8b8d0f2
commit
fda1a6ea9b
3 changed files with 9 additions and 7 deletions
|
|
@ -462,7 +462,7 @@ class LibraryController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Logger.info(`[LibraryController] Removing library item "${libraryItem.id}" from folder "${folder.path}"`)
|
Logger.info(`[LibraryController] Removing library item "${libraryItem.id}" from folder "${folder.path}"`)
|
||||||
await this.handleDeleteLibraryItem(libraryItem.id, mediaItemIds)
|
await this.handleDeleteLibraryItem(libraryItem.id, mediaItemIds, req.library.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authorIds.length) {
|
if (authorIds.length) {
|
||||||
|
|
@ -563,7 +563,7 @@ class LibraryController {
|
||||||
mediaItemIds.push(libraryItem.mediaId)
|
mediaItemIds.push(libraryItem.mediaId)
|
||||||
}
|
}
|
||||||
Logger.info(`[LibraryController] Removing library item "${libraryItem.id}" from library "${req.library.name}"`)
|
Logger.info(`[LibraryController] Removing library item "${libraryItem.id}" from library "${req.library.name}"`)
|
||||||
await this.handleDeleteLibraryItem(libraryItem.id, mediaItemIds)
|
await this.handleDeleteLibraryItem(libraryItem.id, mediaItemIds, req.library.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set PlaybackSessions libraryId to null
|
// Set PlaybackSessions libraryId to null
|
||||||
|
|
@ -714,7 +714,7 @@ class LibraryController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Logger.info(`[LibraryController] Removing library item "${libraryItem.id}" with issue`)
|
Logger.info(`[LibraryController] Removing library item "${libraryItem.id}" with issue`)
|
||||||
await this.handleDeleteLibraryItem(libraryItem.id, mediaItemIds)
|
await this.handleDeleteLibraryItem(libraryItem.id, mediaItemIds, req.library.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authorIds.length) {
|
if (authorIds.length) {
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ class LibraryItemController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.handleDeleteLibraryItem(req.libraryItem.id, mediaItemIds)
|
await this.handleDeleteLibraryItem(req.libraryItem.id, mediaItemIds, req.libraryItem.libraryId)
|
||||||
if (hardDelete) {
|
if (hardDelete) {
|
||||||
Logger.info(`[LibraryItemController] Deleting library item from file system at "${libraryItemPath}"`)
|
Logger.info(`[LibraryItemController] Deleting library item from file system at "${libraryItemPath}"`)
|
||||||
await fs.remove(libraryItemPath).catch((error) => {
|
await fs.remove(libraryItemPath).catch((error) => {
|
||||||
|
|
@ -565,7 +565,7 @@ class LibraryItemController {
|
||||||
authorIds.push(...libraryItem.media.authors.map((au) => au.id))
|
authorIds.push(...libraryItem.media.authors.map((au) => au.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.handleDeleteLibraryItem(libraryItem.id, mediaItemIds)
|
await this.handleDeleteLibraryItem(libraryItem.id, mediaItemIds, libraryItem.libraryId)
|
||||||
if (hardDelete) {
|
if (hardDelete) {
|
||||||
Logger.info(`[LibraryItemController] Deleting library item from file system at "${libraryItemPath}"`)
|
Logger.info(`[LibraryItemController] Deleting library item from file system at "${libraryItemPath}"`)
|
||||||
await fs.remove(libraryItemPath).catch((error) => {
|
await fs.remove(libraryItemPath).catch((error) => {
|
||||||
|
|
|
||||||
|
|
@ -363,8 +363,9 @@ class ApiRouter {
|
||||||
* Remove library item and associated entities
|
* Remove library item and associated entities
|
||||||
* @param {string} libraryItemId
|
* @param {string} libraryItemId
|
||||||
* @param {string[]} mediaItemIds array of bookId or podcastEpisodeId
|
* @param {string[]} mediaItemIds array of bookId or podcastEpisodeId
|
||||||
|
* @param {string} libraryId
|
||||||
*/
|
*/
|
||||||
async handleDeleteLibraryItem(libraryItemId, mediaItemIds) {
|
async handleDeleteLibraryItem(libraryItemId, mediaItemIds, libraryId) {
|
||||||
const numProgressRemoved = await Database.mediaProgressModel.destroy({
|
const numProgressRemoved = await Database.mediaProgressModel.destroy({
|
||||||
where: {
|
where: {
|
||||||
mediaItemId: mediaItemIds
|
mediaItemId: mediaItemIds
|
||||||
|
|
@ -395,7 +396,8 @@ class ApiRouter {
|
||||||
await Database.libraryItemModel.removeById(libraryItemId)
|
await Database.libraryItemModel.removeById(libraryItemId)
|
||||||
|
|
||||||
SocketAuthority.emitter('item_removed', {
|
SocketAuthority.emitter('item_removed', {
|
||||||
id: libraryItemId
|
id: libraryItemId,
|
||||||
|
libraryId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue