Fix podcast re-scan promise

This commit is contained in:
advplyr 2025-04-10 17:39:41 -05:00
parent 7c114a051a
commit 62194b8781

View File

@ -59,17 +59,17 @@ class PodcastScanner {
if (libraryItemData.hasAudioFileChanges || libraryItemData.audioLibraryFiles.length !== existingPodcastEpisodes.length) { if (libraryItemData.hasAudioFileChanges || libraryItemData.audioLibraryFiles.length !== existingPodcastEpisodes.length) {
// Filter out and destroy episodes that were removed // Filter out and destroy episodes that were removed
existingPodcastEpisodes = await Promise.all( const episodesToRemove = []
existingPodcastEpisodes.filter(async (ep) => { existingPodcastEpisodes = existingPodcastEpisodes.filter((ep) => {
if (libraryItemData.checkAudioFileRemoved(ep.audioFile)) { if (libraryItemData.checkAudioFileRemoved(ep.audioFile)) {
libraryScan.addLog(LogLevel.INFO, `Podcast episode "${ep.title}" audio file was removed`) libraryScan.addLog(LogLevel.INFO, `Podcast episode "${ep.title}" audio file was removed`)
// TODO: Should clean up other data linked to this episode episodesToRemove.push(ep)
await ep.destroy() return false
return false }
} return true
return true })
})
) await Promise.all(episodesToRemove.map((ep) => ep.destroy()))
// Update audio files that were modified // Update audio files that were modified
if (libraryItemData.audioLibraryFilesModified.length) { if (libraryItemData.audioLibraryFilesModified.length) {
@ -139,7 +139,6 @@ class PodcastScanner {
} }
let hasMediaChanges = false let hasMediaChanges = false
if (existingPodcastEpisodes.length !== media.numEpisodes) { if (existingPodcastEpisodes.length !== media.numEpisodes) {
media.numEpisodes = existingPodcastEpisodes.length media.numEpisodes = existingPodcastEpisodes.length
hasMediaChanges = true hasMediaChanges = true