mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +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 | ||||
|     } | ||||
|     Logger.debug(`[Watcher] Rename ${pathFrom} => ${pathTo}`) | ||||
|     this.addFileUpdate(libraryId, pathFrom, 'renamed') | ||||
|     this.addFileUpdate(libraryId, pathTo, 'renamed') | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -5,6 +5,7 @@ const Path = require('path') | ||||
| const Logger = require('../Logger') | ||||
| const { groupFilesIntoLibraryItemPaths, getLibraryItemFileData, scanFolder } = require('../utils/scandir') | ||||
| const { comparePaths } = require('../utils/index') | ||||
| const { getIno } = require('../utils/fileUtils') | ||||
| const { ScanResult, LogLevel } = require('../utils/constants') | ||||
| 
 | ||||
| const AudioFileScanner = require('./AudioFileScanner') | ||||
| @ -538,9 +539,19 @@ class Scanner { | ||||
|     var itemGroupingResults = {} | ||||
|     for (const itemDir in fileUpdateGroup) { | ||||
|       var fullPath = Path.posix.join(folder.fullPath.replace(/\\/g, '/'), itemDir) | ||||
|       const dirIno = await getIno(fullPath) | ||||
| 
 | ||||
|       // Check if book dir group is already an item
 | ||||
|       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) { | ||||
|         // Is the item exactly - check if was deleted
 | ||||
|         if (existingLibraryItem.path === fullPath) { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user