mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-29 01:58:49 +01:00
Fix:Watcher & scanner on folder renames to check inode value and update existing library item paths
This commit is contained in:
parent
639c930779
commit
474a7d08d0
@ -140,7 +140,6 @@ class FolderWatcher extends EventEmitter {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
Logger.debug(`[Watcher] Rename ${pathFrom} => ${pathTo}`)
|
Logger.debug(`[Watcher] Rename ${pathFrom} => ${pathTo}`)
|
||||||
this.addFileUpdate(libraryId, pathFrom, 'renamed')
|
|
||||||
this.addFileUpdate(libraryId, pathTo, 'renamed')
|
this.addFileUpdate(libraryId, pathTo, 'renamed')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ const Path = require('path')
|
|||||||
const Logger = require('../Logger')
|
const Logger = require('../Logger')
|
||||||
const { groupFilesIntoLibraryItemPaths, getLibraryItemFileData, scanFolder } = require('../utils/scandir')
|
const { groupFilesIntoLibraryItemPaths, getLibraryItemFileData, scanFolder } = require('../utils/scandir')
|
||||||
const { comparePaths } = require('../utils/index')
|
const { comparePaths } = require('../utils/index')
|
||||||
|
const { getIno } = require('../utils/fileUtils')
|
||||||
const { ScanResult, LogLevel } = require('../utils/constants')
|
const { ScanResult, LogLevel } = require('../utils/constants')
|
||||||
|
|
||||||
const AudioFileScanner = require('./AudioFileScanner')
|
const AudioFileScanner = require('./AudioFileScanner')
|
||||||
@ -538,9 +539,19 @@ class Scanner {
|
|||||||
var itemGroupingResults = {}
|
var itemGroupingResults = {}
|
||||||
for (const itemDir in fileUpdateGroup) {
|
for (const itemDir in fileUpdateGroup) {
|
||||||
var fullPath = Path.posix.join(folder.fullPath.replace(/\\/g, '/'), itemDir)
|
var fullPath = Path.posix.join(folder.fullPath.replace(/\\/g, '/'), itemDir)
|
||||||
|
const dirIno = await getIno(fullPath)
|
||||||
|
|
||||||
// Check if book dir group is already an item
|
// Check if book dir group is already an item
|
||||||
var existingLibraryItem = this.db.libraryItems.find(li => fullPath.startsWith(li.path))
|
var existingLibraryItem = this.db.libraryItems.find(li => fullPath.startsWith(li.path))
|
||||||
|
if (!existingLibraryItem) {
|
||||||
|
existingLibraryItem = this.db.libraryItems.find(li => li.ino === dirIno)
|
||||||
|
if (existingLibraryItem) {
|
||||||
|
Logger.debug(`[Scanner] scanFolderUpdates: Library item found by inode value "${existingLibraryItem.relPath} => ${itemDir}"`)
|
||||||
|
// Update library item paths for scan and all library item paths will get updated in LibraryItem.checkScanData
|
||||||
|
existingLibraryItem.path = fullPath
|
||||||
|
existingLibraryItem.relPath = itemDir
|
||||||
|
}
|
||||||
|
}
|
||||||
if (existingLibraryItem) {
|
if (existingLibraryItem) {
|
||||||
// Is the item exactly - check if was deleted
|
// Is the item exactly - check if was deleted
|
||||||
if (existingLibraryItem.path === fullPath) {
|
if (existingLibraryItem.path === fullPath) {
|
||||||
|
Loading…
Reference in New Issue
Block a user