mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-25 16:45:05 +00:00
Improve logging when creating preview images
This commit is contained in:
parent
ed26fe226b
commit
746e04c624
@ -47,7 +47,7 @@ object MakePreviewTask {
|
||||
_ <- ra
|
||||
.map(AttachmentPreview.createPreview(ctx, preview, cfg.chunkSize))
|
||||
.getOrElse(
|
||||
ctx.logger.warn(s"No attachment found with id: ${ctx.args.attachment}")
|
||||
ctx.logger.error(s"No attachment found with id: ${ctx.args.attachment}")
|
||||
)
|
||||
} yield ()
|
||||
|
||||
|
@ -57,13 +57,17 @@ object AttachmentPreview {
|
||||
case MimeType.PdfMatch(_) =>
|
||||
preview.previewPNG(loadFile(ctx)(ra)).flatMap {
|
||||
case Some(out) =>
|
||||
createRecord(ctx, out, ra, chunkSize).map(_.some)
|
||||
ctx.logger.debug("Preview generated, saving to database…") *>
|
||||
createRecord(ctx, out, ra, chunkSize).map(_.some)
|
||||
case None =>
|
||||
(None: Option[RAttachmentPreview]).pure[F]
|
||||
ctx.logger
|
||||
.info(s"Preview could not be generated. Maybe the pdf has no pages?") *>
|
||||
(None: Option[RAttachmentPreview]).pure[F]
|
||||
}
|
||||
|
||||
case _ =>
|
||||
(None: Option[RAttachmentPreview]).pure[F]
|
||||
case mt =>
|
||||
ctx.logger.warn(s"Not a pdf file, but ${mt.asString}, cannot get page count.") *>
|
||||
(None: Option[RAttachmentPreview]).pure[F]
|
||||
}
|
||||
|
||||
private def createRecord[F[_]: Sync](
|
||||
|
Loading…
x
Reference in New Issue
Block a user