mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-18 17:59:37 +00:00
Fix deleting episode library file removes episode from playlist #3784
This commit is contained in:
parent
de7296eaab
commit
63466ec48b
4 changed files with 67 additions and 30 deletions
|
|
@ -695,6 +695,27 @@ class Database {
|
|||
await book.destroy()
|
||||
}
|
||||
|
||||
const playlistMediaItemsWithNoMediaItem = await this.playlistMediaItemModel.findAll({
|
||||
include: [
|
||||
{
|
||||
model: this.bookModel,
|
||||
attributes: ['id']
|
||||
},
|
||||
{
|
||||
model: this.podcastEpisodeModel,
|
||||
attributes: ['id']
|
||||
}
|
||||
],
|
||||
where: {
|
||||
'$book.id$': null,
|
||||
'$podcastEpisode.id$': null
|
||||
}
|
||||
})
|
||||
for (const playlistMediaItem of playlistMediaItemsWithNoMediaItem) {
|
||||
Logger.warn(`Found playlistMediaItem with no book or podcastEpisode - removing it`)
|
||||
await playlistMediaItem.destroy()
|
||||
}
|
||||
|
||||
// Remove empty series
|
||||
const emptySeries = await this.seriesModel.findAll({
|
||||
include: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue