From 6467a92de6db0c9fe4eb5a492fe5272de68922e7 Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 3 Jan 2025 12:12:56 -0600 Subject: [PATCH] Remove media progress when deleting podcast episode audio file --- server/controllers/LibraryItemController.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 5a46be4b..4da68866 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -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)