Skip to content

Commit

Permalink
Remove media progress when deleting podcast episode audio file
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Jan 3, 2025
1 parent 63466ec commit 6467a92
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/controllers/LibraryItemController.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,20 @@ class LibraryItemController {
}
} else if (req.libraryItem.media.podcastEpisodes.some((ep) => ep.audioFile.ino === req.params.fileid)) {
const episodeToRemove = req.libraryItem.media.podcastEpisodes.find((ep) => ep.audioFile.ino === req.params.fileid)
// Remove episode from all playlists
await Database.playlistModel.removeMediaItemsFromPlaylists([episodeToRemove.id])

// Remove episode media progress
const numProgressRemoved = await Database.mediaProgressModel.destroy({
where: {
mediaItemId: episodeToRemove.id
}
})
if (numProgressRemoved > 0) {
Logger.info(`[LibraryItemController] Removed media progress for episode ${episodeToRemove.id}`)
}

// Remove episode
await episodeToRemove.destroy()

req.libraryItem.media.podcastEpisodes = req.libraryItem.media.podcastEpisodes.filter((ep) => ep.audioFile.ino !== req.params.fileid)
Expand Down

0 comments on commit 6467a92

Please sign in to comment.