mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Merge pull request #2283 from mikiher/watcher-single-file-update
Fix handling of single media file updates
This commit is contained in:
commit
5ce1cda2d0
@ -463,7 +463,7 @@ class LibraryScanner {
|
|||||||
// Test Case: Moving audio files from library item folder to author folder should trigger a re-scan of the item
|
// Test Case: Moving audio files from library item folder to author folder should trigger a re-scan of the item
|
||||||
const updateGroup = { ...fileUpdateGroup }
|
const updateGroup = { ...fileUpdateGroup }
|
||||||
for (const itemDir in updateGroup) {
|
for (const itemDir in updateGroup) {
|
||||||
if (itemDir == fileUpdateGroup[itemDir]) continue // Media in root path
|
if (isSingleMediaFile(fileUpdateGroup, itemDir)) continue // Media in root path
|
||||||
|
|
||||||
const itemDirNestedFiles = fileUpdateGroup[itemDir].filter(b => b.includes('/'))
|
const itemDirNestedFiles = fileUpdateGroup[itemDir].filter(b => b.includes('/'))
|
||||||
if (!itemDirNestedFiles.length) continue
|
if (!itemDirNestedFiles.length) continue
|
||||||
@ -559,7 +559,7 @@ class LibraryScanner {
|
|||||||
Logger.debug(`[LibraryScanner] Folder update for relative path "${itemDir}" is in library item "${existingLibraryItem.media.metadata.title}" - scan for updates`)
|
Logger.debug(`[LibraryScanner] Folder update for relative path "${itemDir}" is in library item "${existingLibraryItem.media.metadata.title}" - scan for updates`)
|
||||||
itemGroupingResults[itemDir] = await LibraryItemScanner.scanLibraryItem(existingLibraryItem.id, renamedPaths)
|
itemGroupingResults[itemDir] = await LibraryItemScanner.scanLibraryItem(existingLibraryItem.id, renamedPaths)
|
||||||
continue
|
continue
|
||||||
} else if (library.settings.audiobooksOnly && !fileUpdateGroup[itemDir].some?.(scanUtils.checkFilepathIsAudioFile)) {
|
} else if (library.settings.audiobooksOnly && !hasAudioFiles(fileUpdateGroup, itemDir)) {
|
||||||
Logger.debug(`[LibraryScanner] Folder update for relative path "${itemDir}" has no audio files`)
|
Logger.debug(`[LibraryScanner] Folder update for relative path "${itemDir}" has no audio files`)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -580,7 +580,7 @@ class LibraryScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logger.debug(`[LibraryScanner] Folder update group must be a new item "${itemDir}" in library "${library.name}"`)
|
Logger.debug(`[LibraryScanner] Folder update group must be a new item "${itemDir}" in library "${library.name}"`)
|
||||||
const isSingleMediaItem = itemDir === fileUpdateGroup[itemDir]
|
const isSingleMediaItem = isSingleMediaFile(fileUpdateGroup, itemDir)
|
||||||
const newLibraryItem = await LibraryItemScanner.scanPotentialNewLibraryItem(fullPath, library, folder, isSingleMediaItem)
|
const newLibraryItem = await LibraryItemScanner.scanPotentialNewLibraryItem(fullPath, library, folder, isSingleMediaItem)
|
||||||
if (newLibraryItem) {
|
if (newLibraryItem) {
|
||||||
const oldNewLibraryItem = Database.libraryItemModel.getOldLibraryItem(newLibraryItem)
|
const oldNewLibraryItem = Database.libraryItemModel.getOldLibraryItem(newLibraryItem)
|
||||||
@ -592,4 +592,14 @@ class LibraryScanner {
|
|||||||
return itemGroupingResults
|
return itemGroupingResults
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = new LibraryScanner()
|
module.exports = new LibraryScanner()
|
||||||
|
|
||||||
|
function hasAudioFiles(fileUpdateGroup, itemDir) {
|
||||||
|
return isSingleMediaFile(fileUpdateGroup, itemDir) ?
|
||||||
|
scanUtils.checkFilepathIsAudioFile(fileUpdateGroup[itemDir]) :
|
||||||
|
fileUpdateGroup[itemDir].some(scanUtils.checkFilepathIsAudioFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSingleMediaFile(fileUpdateGroup, itemDir) {
|
||||||
|
return itemDir === fileUpdateGroup[itemDir]
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user