mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-22 00:07:52 +01:00
Fix:Server crash when scanning in invalid epub #2856
This commit is contained in:
parent
9102a0045f
commit
359a2752d8
@ -18,7 +18,10 @@ async function extractFileFromEpub(epubPath, filepath) {
|
||||
Logger.error(`[parseEpubMetadata] Failed to extract ${filepath} from epub at "${epubPath}"`, error)
|
||||
})
|
||||
const filedata = data?.toString('utf8')
|
||||
await zip.close()
|
||||
await zip.close().catch((error) => {
|
||||
Logger.error(`[parseEpubMetadata] Failed to close zip`, error)
|
||||
})
|
||||
|
||||
return filedata
|
||||
}
|
||||
|
||||
@ -68,6 +71,9 @@ async function parse(ebookFile) {
|
||||
Logger.debug(`Parsing metadata from epub at "${epubPath}"`)
|
||||
// Entrypoint of the epub that contains the filepath to the package document (opf file)
|
||||
const containerJson = await extractXmlToJson(epubPath, 'META-INF/container.xml')
|
||||
if (!containerJson) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Get package document opf filepath from container.xml
|
||||
const packageDocPath = containerJson.container?.rootfiles?.[0]?.rootfile?.[0]?.$?.['full-path']
|
||||
|
Loading…
Reference in New Issue
Block a user