Skip to content

Commit

Permalink
fix: fixed invalid cover path
Browse files Browse the repository at this point in the history
  • Loading branch information
mbret committed Dec 16, 2024
1 parent b930338 commit ee7ad83
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const retrieveMetadataAndSaveCover = async (
db: nano.DocumentScope<unknown>
}
) => {
logger.info(
console.log(
`[retrieveMetadataAndSaveCover]`,
`syncMetadata run for user ${ctx.userName} with book ${ctx.book._id}`
)
let bookNameForDebug = ""
Expand All @@ -37,6 +38,7 @@ export const retrieveMetadataAndSaveCover = async (
bookNameForDebug = reduceMetadata(ctx.book.metadata).title || ""

console.log(
`[retrieveMetadataAndSaveCover]`,
`processing ${ctx.book._id} with link of type ${ctx.link.type}`,
{ link: ctx.link }
)
Expand Down Expand Up @@ -118,11 +120,15 @@ export const retrieveMetadataAndSaveCover = async (
fileToUnlink = tmpFilePath
contentType = downloadMetadata.contentType || contentType

console.log(`syncMetadata processing ${ctx.book._id}`, {
linkMetadata,
contentType,
tmpFilePath
})
console.log(
`[retrieveMetadataAndSaveCover]`,
`syncMetadata processing ${ctx.book._id}`,
{
linkMetadata,
contentType,
tmpFilePath
}
)

const isRarArchive = contentType === "application/x-rar"
let archiveExtractor: Extractor<Uint8Array> | undefined = undefined
Expand Down Expand Up @@ -174,7 +180,9 @@ export const retrieveMetadataAndSaveCover = async (
})

console.log(
`metadataDaemon Finished processing book ${ctx.book._id} with resource id ${ctx.link.resourceId}`
`[retrieveMetadataAndSaveCover]`,
`prepare to update ${ctx.book._id} with`,
{ metadataList }
)

await atomicUpdate(ctx.db, "book", ctx.book._id, (old) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ export const getMetadataFromZipArchive = async (
* Path in the archive to the cover image
*/
coverLink: opfCoverLink
? `${opfBasePath}/${opfCoverLink}`
? opfBasePath !== ""
? `${opfBasePath}/${opfCoverLink}`
: opfCoverLink
: firstValidImagePath
}
}

0 comments on commit ee7ad83

Please sign in to comment.