Compare commits

...
4 Commits
Author SHA1 Message Date
advplyrandGitHub 1b46d68027 Merge pull request #5429 from Vito0912/fix/npmv12
add npmv12 compatibility
2026-08-03 17:14:55 -05:00
Finn Dittmar d511612f21 add npmv12 compatibility 2026-08-03 21:08:18 +02:00
advplyrandGitHub 6caa1aa2da Merge pull request #5409 from mikiher/podcast-scanner-stale-episodes
Fix podcast rescan emitting stale episodes on item_updated
2026-07-28 18:15:19 -04:00
mikiher 32fae4a7c6 Fix podcast rescan emitting stale episodes on item_updated 2026-07-28 12:26:32 +03:00
3 changed files with 30 additions and 2 deletions
+15
View File
@@ -2113,6 +2113,21 @@
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
"devOptional": true "devOptional": true
}, },
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": { "node_modules/function-bind": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
+3
View File
@@ -65,5 +65,8 @@
"nodemon": "^2.0.20", "nodemon": "^2.0.20",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"sinon": "^17.0.1" "sinon": "^17.0.1"
},
"allowScripts": {
"sqlite3@5.1.7": true
} }
} }
+12 -2
View File
@@ -58,8 +58,12 @@ class PodcastScanner {
/** @type {AudioFile[]} */ /** @type {AudioFile[]} */
let newAudioFiles = [] let newAudioFiles = []
// Track episode add/remove/update so item_updated includes the current episode list
let hasEpisodeChanges = false
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.
// filter() returns a new array — reassign to media.podcastEpisodes before emit.
const episodesToRemove = [] const episodesToRemove = []
existingPodcastEpisodes = existingPodcastEpisodes.filter((ep) => { existingPodcastEpisodes = existingPodcastEpisodes.filter((ep) => {
if (libraryItemData.checkAudioFileRemoved(ep.audioFile)) { if (libraryItemData.checkAudioFileRemoved(ep.audioFile)) {
@@ -70,6 +74,7 @@ class PodcastScanner {
}) })
if (episodesToRemove.length) { if (episodesToRemove.length) {
hasEpisodeChanges = true
// Remove episodes from playlists and media progress // Remove episodes from playlists and media progress
const episodeIds = episodesToRemove.map((ep) => ep.id) const episodeIds = episodesToRemove.map((ep) => ep.id)
await Database.playlistModel.removeMediaItemsFromPlaylists(episodeIds) await Database.playlistModel.removeMediaItemsFromPlaylists(episodeIds)
@@ -116,6 +121,7 @@ class PodcastScanner {
AudioFileScanner.setPodcastEpisodeMetadataFromAudioMetaTags(podcastEpisode, libraryScan) AudioFileScanner.setPodcastEpisodeMetadataFromAudioMetaTags(podcastEpisode, libraryScan)
libraryScan.addLog(LogLevel.INFO, `Podcast episode "${podcastEpisode.title}" keys changed [${podcastEpisode.changed()?.join(', ')}]`) libraryScan.addLog(LogLevel.INFO, `Podcast episode "${podcastEpisode.title}" keys changed [${podcastEpisode.changed()?.join(', ')}]`)
await podcastEpisode.save() await podcastEpisode.save()
hasEpisodeChanges = true
} }
} }
@@ -155,9 +161,13 @@ class PodcastScanner {
libraryScan.addLog(LogLevel.INFO, `New Podcast episode "${newPodcastEpisode.title}" added`) libraryScan.addLog(LogLevel.INFO, `New Podcast episode "${newPodcastEpisode.title}" added`)
await newPodcastEpisode.save() await newPodcastEpisode.save()
existingPodcastEpisodes.push(newPodcastEpisode) existingPodcastEpisodes.push(newPodcastEpisode)
hasEpisodeChanges = true
} }
} }
// Keep association in sync for toOldJSONExpanded() / item_updated socket payload
media.podcastEpisodes = existingPodcastEpisodes
let hasMediaChanges = false let hasMediaChanges = false
if (existingPodcastEpisodes.length !== media.numEpisodes) { if (existingPodcastEpisodes.length !== media.numEpisodes) {
media.numEpisodes = existingPodcastEpisodes.length media.numEpisodes = existingPodcastEpisodes.length
@@ -250,7 +260,7 @@ class PodcastScanner {
return { return {
libraryItem: existingLibraryItem, libraryItem: existingLibraryItem,
wasUpdated: hasMediaChanges || libraryItemUpdated wasUpdated: hasMediaChanges || libraryItemUpdated || hasEpisodeChanges
} }
} }