Fix:Remove podcast episode to also remove library file #636

This commit is contained in:
advplyr 2022-06-01 17:45:52 -05:00
parent 4621c78573
commit 36bd6e649a
3 changed files with 21 additions and 2 deletions

View File

@ -219,7 +219,11 @@ class PodcastController {
}) })
} }
libraryItem.media.removeEpisode(episodeId) // Remove episode from Podcast and library file
const episodeRemoved = libraryItem.media.removeEpisode(episodeId)
if (episodeRemoved && episodeRemoved.audioFile) {
libraryItem.removeLibraryFile(episodeRemoved.audioFile.ino)
}
await this.db.updateLibraryItem(libraryItem) await this.db.updateLibraryItem(libraryItem)
this.emitter('item_updated', libraryItem.toJSONExpanded()) this.emitter('item_updated', libraryItem.toJSONExpanded())

View File

@ -482,5 +482,16 @@ class LibraryItem {
return success return success
}) })
} }
removeLibraryFile(ino) {
if (!ino) return false
var libraryFile = this.libraryFiles.find(lf => lf.ino === ino)
if (libraryFile) {
this.libraryFiles = this.libraryFiles.filter(lf => lf.ino !== ino)
this.updatedAt = Date.now()
return true
}
return false
}
} }
module.exports = LibraryItem module.exports = LibraryItem

View File

@ -240,7 +240,11 @@ class Podcast {
} }
removeEpisode(episodeId) { removeEpisode(episodeId) {
this.episodes = this.episodes.filter(ep => ep.id !== episodeId) const episode = this.episodes.find(ep => ep.id === episodeId)
if (episode) {
this.episodes = this.episodes.filter(ep => ep.id !== episodeId)
}
return episode
} }
getPlaybackTitle(episodeId) { getPlaybackTitle(episodeId) {