mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-27 03:09:43 +02:00
Fix:Server crash when scanning in invalid epub #2856
This commit is contained in:
parent
9102a0045f
commit
359a2752d8
1 changed files with 7 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue