mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Cleanup scanner
This commit is contained in:
		
							parent
							
								
									55fdc48d5d
								
							
						
					
					
						commit
						589c4f73d2
					
				| @ -68,7 +68,7 @@ class Scanner { | |||||||
| 
 | 
 | ||||||
|   async scanLibraryItem(libraryMediaType, folder, libraryItem) { |   async scanLibraryItem(libraryMediaType, folder, libraryItem) { | ||||||
|     // TODO: Support for single media item
 |     // TODO: Support for single media item
 | ||||||
|     const libraryItemData = await getLibraryItemFileData(libraryMediaType, folder, libraryItem.path, false, this.db.serverSettings) |     const libraryItemData = await getLibraryItemFileData(libraryMediaType, folder, libraryItem.path, false) | ||||||
|     if (!libraryItemData) { |     if (!libraryItemData) { | ||||||
|       return ScanResult.NOTHING |       return ScanResult.NOTHING | ||||||
|     } |     } | ||||||
| @ -173,7 +173,7 @@ class Scanner { | |||||||
|     // Scan each library
 |     // Scan each library
 | ||||||
|     for (let i = 0; i < libraryScan.folders.length; i++) { |     for (let i = 0; i < libraryScan.folders.length; i++) { | ||||||
|       const folder = libraryScan.folders[i] |       const folder = libraryScan.folders[i] | ||||||
|       const itemDataFoundInFolder = await scanFolder(libraryScan.libraryMediaType, folder, this.db.serverSettings) |       const itemDataFoundInFolder = await scanFolder(libraryScan.libraryMediaType, folder) | ||||||
|       libraryScan.addLog(LogLevel.INFO, `${itemDataFoundInFolder.length} item data found in folder "${folder.fullPath}"`) |       libraryScan.addLog(LogLevel.INFO, `${itemDataFoundInFolder.length} item data found in folder "${folder.fullPath}"`) | ||||||
|       libraryItemDataFound = libraryItemDataFound.concat(itemDataFoundInFolder) |       libraryItemDataFound = libraryItemDataFound.concat(itemDataFoundInFolder) | ||||||
|     } |     } | ||||||
| @ -632,7 +632,7 @@ class Scanner { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async scanPotentialNewLibraryItem(libraryMediaType, folder, fullPath, isSingleMediaItem = false) { |   async scanPotentialNewLibraryItem(libraryMediaType, folder, fullPath, isSingleMediaItem = false) { | ||||||
|     const libraryItemData = await getLibraryItemFileData(libraryMediaType, folder, fullPath, isSingleMediaItem, this.db.serverSettings) |     const libraryItemData = await getLibraryItemFileData(libraryMediaType, folder, fullPath, isSingleMediaItem) | ||||||
|     if (!libraryItemData) return null |     if (!libraryItemData) return null | ||||||
|     return this.scanNewLibraryItem(libraryItemData, libraryMediaType) |     return this.scanNewLibraryItem(libraryItemData, libraryMediaType) | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -175,7 +175,7 @@ function cleanFileObjects(libraryItemPath, files) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Scan folder
 | // Scan folder
 | ||||||
| async function scanFolder(libraryMediaType, folder, serverSettings = {}) { | async function scanFolder(libraryMediaType, folder) { | ||||||
|   const folderPath = filePathToPOSIX(folder.fullPath) |   const folderPath = filePathToPOSIX(folder.fullPath) | ||||||
| 
 | 
 | ||||||
|   const pathExists = await fs.pathExists(folderPath) |   const pathExists = await fs.pathExists(folderPath) | ||||||
| @ -216,7 +216,7 @@ async function scanFolder(libraryMediaType, folder, serverSettings = {}) { | |||||||
|       fileObjs = await cleanFileObjects(folderPath, [libraryItemPath]) |       fileObjs = await cleanFileObjects(folderPath, [libraryItemPath]) | ||||||
|       isFile = true |       isFile = true | ||||||
|     } else { |     } else { | ||||||
|       libraryItemData = getDataFromMediaDir(libraryMediaType, folderPath, libraryItemPath, serverSettings, libraryItemGrouping[libraryItemPath]) |       libraryItemData = getDataFromMediaDir(libraryMediaType, folderPath, libraryItemPath) | ||||||
|       fileObjs = await cleanFileObjects(libraryItemData.path, libraryItemGrouping[libraryItemPath]) |       fileObjs = await cleanFileObjects(libraryItemData.path, libraryItemGrouping[libraryItemPath]) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -347,19 +347,18 @@ function getPodcastDataFromDir(folderPath, relPath) { | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getDataFromMediaDir(libraryMediaType, folderPath, relPath, serverSettings, fileNames) { | function getDataFromMediaDir(libraryMediaType, folderPath, relPath) { | ||||||
|   if (libraryMediaType === 'podcast') { |   if (libraryMediaType === 'podcast') { | ||||||
|     return getPodcastDataFromDir(folderPath, relPath) |     return getPodcastDataFromDir(folderPath, relPath) | ||||||
|   } else if (libraryMediaType === 'book') { |   } else if (libraryMediaType === 'book') { | ||||||
|     var parseSubtitle = !!serverSettings.scannerParseSubtitle |     return getBookDataFromDir(folderPath, relPath, !!global.ServerSettings.scannerParseSubtitle) | ||||||
|     return getBookDataFromDir(folderPath, relPath, parseSubtitle) |  | ||||||
|   } else { |   } else { | ||||||
|     return getPodcastDataFromDir(folderPath, relPath) |     return getPodcastDataFromDir(folderPath, relPath) | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Called from Scanner.js
 | // Called from Scanner.js
 | ||||||
| async function getLibraryItemFileData(libraryMediaType, folder, libraryItemPath, isSingleMediaItem, serverSettings = {}) { | async function getLibraryItemFileData(libraryMediaType, folder, libraryItemPath, isSingleMediaItem) { | ||||||
|   libraryItemPath = filePathToPOSIX(libraryItemPath) |   libraryItemPath = filePathToPOSIX(libraryItemPath) | ||||||
|   const folderFullPath = filePathToPOSIX(folder.fullPath) |   const folderFullPath = filePathToPOSIX(folder.fullPath) | ||||||
| 
 | 
 | ||||||
| @ -384,8 +383,7 @@ async function getLibraryItemFileData(libraryMediaType, folder, libraryItemPath, | |||||||
|     } |     } | ||||||
|   } else { |   } else { | ||||||
|     fileItems = await recurseFiles(libraryItemPath) |     fileItems = await recurseFiles(libraryItemPath) | ||||||
|     const fileNames = fileItems.map(i => i.name) |     libraryItemData = getDataFromMediaDir(libraryMediaType, folderFullPath, libraryItemDir) | ||||||
|     libraryItemData = getDataFromMediaDir(libraryMediaType, folderFullPath, libraryItemDir, serverSettings, fileNames) |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   const libraryItemDirStats = await getFileTimestampsWithIno(libraryItemData.path) |   const libraryItemDirStats = await getFileTimestampsWithIno(libraryItemData.path) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user