Fix converted filename

Mark it by default with a string from the config file.

Issue: 397
This commit is contained in:
Eike Kettner
2020-11-08 01:23:07 +01:00
parent ef7cb4e779
commit 6db5c39d78
4 changed files with 12 additions and 1 deletions

View File

@ -328,6 +328,11 @@ docspell.joex {
# as used with the rest server.
chunk-size = 524288
# A string used to change the filename of the converted pdf file.
# If empty, the original file name is used for the pdf file ( the
# extension is always replaced with `pdf`).
converted-filename-part = "converted"
# When reading images, this is the maximum size. Images that are
# larger are not processed.
max-image-size = ${docspell.joex.extraction.ocr.max-image-size}

View File

@ -135,7 +135,11 @@ object ConvertPdf {
) = {
val hint =
MimeTypeHint.advertised(MimeType.pdf).withName(ra.name.getOrElse("file.pdf"))
val newName = ra.name.map(n => s"$n.pdf")
val newName =
ra.name
.map(FileName.apply)
.map(_.withExtension("pdf").withPart(cfg.convertedFilenamePart, '.'))
.map(_.fullName)
ctx.store.bitpeace
.saveNew(pdf, cfg.chunkSize, MimetypeHint(hint.filename, hint.advertised))
.compile