mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Merge pull request #3312 from nichwall/close_comics_during_scan
Close comics during scan
This commit is contained in:
		
						commit
						f66cea9829
					
				| @ -12,7 +12,7 @@ const parseComicInfoMetadata = require('./parseComicInfoMetadata') | |||||||
|  * @returns {Promise<Buffer>} |  * @returns {Promise<Buffer>} | ||||||
|  */ |  */ | ||||||
| async function getComicFileBuffer(filepath) { | async function getComicFileBuffer(filepath) { | ||||||
|   if (!await fs.pathExists(filepath)) { |   if (!(await fs.pathExists(filepath))) { | ||||||
|     Logger.error(`Comic path does not exist "${filepath}"`) |     Logger.error(`Comic path does not exist "${filepath}"`) | ||||||
|     return null |     return null | ||||||
|   } |   } | ||||||
| @ -50,6 +50,9 @@ async function extractCoverImage(comicPath, comicImageFilepath, outputCoverPath) | |||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     Logger.error(`[parseComicMetadata] Failed to extract image from comicPath "${comicPath}"`, error) |     Logger.error(`[parseComicMetadata] Failed to extract image from comicPath "${comicPath}"`, error) | ||||||
|     return false |     return false | ||||||
|  |   } finally { | ||||||
|  |     // Ensure we free the memory
 | ||||||
|  |     archive.close() | ||||||
|   } |   } | ||||||
| } | } | ||||||
| module.exports.extractCoverImage = extractCoverImage | module.exports.extractCoverImage = extractCoverImage | ||||||
| @ -79,7 +82,7 @@ async function parse(ebookFile) { | |||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|   let metadata = null |   let metadata = null | ||||||
|   const comicInfo = fileObjects.find(fo => fo.file.name === 'ComicInfo.xml') |   const comicInfo = fileObjects.find((fo) => fo.file.name === 'ComicInfo.xml') | ||||||
|   if (comicInfo) { |   if (comicInfo) { | ||||||
|     const comicInfoEntry = await comicInfo.file.extract() |     const comicInfoEntry = await comicInfo.file.extract() | ||||||
|     if (comicInfoEntry?.fileData) { |     if (comicInfoEntry?.fileData) { | ||||||
| @ -97,13 +100,16 @@ async function parse(ebookFile) { | |||||||
|     metadata |     metadata | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   const firstImage = fileObjects.find(fo => globals.SupportedImageTypes.includes(Path.extname(fo.file.name).toLowerCase().slice(1))) |   const firstImage = fileObjects.find((fo) => globals.SupportedImageTypes.includes(Path.extname(fo.file.name).toLowerCase().slice(1))) | ||||||
|   if (firstImage?.file?._path) { |   if (firstImage?.file?._path) { | ||||||
|     payload.ebookCoverPath = firstImage.file._path |     payload.ebookCoverPath = firstImage.file._path | ||||||
|   } else { |   } else { | ||||||
|     Logger.warn(`Cover image not found in comic at "${comicPath}"`) |     Logger.warn(`Cover image not found in comic at "${comicPath}"`) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   // Ensure we close the archive to free memory
 | ||||||
|  |   archive.close() | ||||||
|  | 
 | ||||||
|   return payload |   return payload | ||||||
| } | } | ||||||
| module.exports.parse = parse | module.exports.parse = parse | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user