mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-03-05 00:18:30 +01:00
Fix watcher scanner detecting existing items
This commit is contained in:
parent
f02992dd4d
commit
934c0b9093
@ -448,10 +448,10 @@ class LibraryScanner {
|
|||||||
const itemGroupingResults = {}
|
const itemGroupingResults = {}
|
||||||
for (const itemDir in fileUpdateGroup) {
|
for (const itemDir in fileUpdateGroup) {
|
||||||
const fullPath = Path.posix.join(fileUtils.filePathToPOSIX(folder.path), itemDir)
|
const fullPath = Path.posix.join(fileUtils.filePathToPOSIX(folder.path), itemDir)
|
||||||
const dirIno = await fileUtils.getIno(fullPath)
|
|
||||||
|
|
||||||
const itemDirParts = itemDir.split('/').slice(0, -1)
|
const itemDirParts = itemDir.split('/').slice(0, -1)
|
||||||
const potentialChildDirs = []
|
|
||||||
|
const potentialChildDirs = [fullPath]
|
||||||
for (let i = 0; i < itemDirParts.length; i++) {
|
for (let i = 0; i < itemDirParts.length; i++) {
|
||||||
potentialChildDirs.push(Path.posix.join(fileUtils.filePathToPOSIX(folder.path), itemDir.split('/').slice(0, -1 - i).join('/')))
|
potentialChildDirs.push(Path.posix.join(fileUtils.filePathToPOSIX(folder.path), itemDir.split('/').slice(0, -1 - i).join('/')))
|
||||||
}
|
}
|
||||||
@ -462,6 +462,7 @@ class LibraryScanner {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (!existingLibraryItem) {
|
if (!existingLibraryItem) {
|
||||||
|
const dirIno = await fileUtils.getIno(fullPath)
|
||||||
existingLibraryItem = await Database.libraryItemModel.findOneOld({
|
existingLibraryItem = await Database.libraryItemModel.findOneOld({
|
||||||
ino: dirIno
|
ino: dirIno
|
||||||
})
|
})
|
||||||
|
@ -86,10 +86,24 @@ function groupFilesIntoLibraryItemPaths(mediaType, paths) {
|
|||||||
|
|
||||||
// Step 4: Add in non-media files if they fit into item group
|
// Step 4: Add in non-media files if they fit into item group
|
||||||
if (nonMediaFilePaths.length) {
|
if (nonMediaFilePaths.length) {
|
||||||
|
|
||||||
for (const nonMediaFilePath of nonMediaFilePaths) {
|
for (const nonMediaFilePath of nonMediaFilePaths) {
|
||||||
const pathDir = Path.dirname(nonMediaFilePath)
|
const pathDir = Path.dirname(nonMediaFilePath)
|
||||||
if (itemGroup[pathDir]) {
|
const filename = Path.basename(nonMediaFilePath)
|
||||||
itemGroup[pathDir].push(nonMediaFilePath)
|
const dirparts = pathDir.split('/')
|
||||||
|
const numparts = dirparts.length
|
||||||
|
let _path = ''
|
||||||
|
|
||||||
|
// Iterate over directories in path
|
||||||
|
for (let i = 0; i < numparts; i++) {
|
||||||
|
const dirpart = dirparts.shift()
|
||||||
|
_path = Path.posix.join(_path, dirpart)
|
||||||
|
if (itemGroup[_path]) { // Directory is a group
|
||||||
|
const relpath = Path.posix.join(dirparts.join('/'), filename)
|
||||||
|
itemGroup[_path].push(relpath)
|
||||||
|
} else if (!dirparts.length) {
|
||||||
|
itemGroup[_path] = [filename]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user