From 7c260add4d471d6dce3e93b40e8da31d434f0098 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Sat, 7 Sep 2019 10:50:26 +0800 Subject: [PATCH] fixed a bug with the new PdfExtractor where Pdfs would have an extra page, generating an error when requested --- komga/build.gradle.kts | 2 +- .../org/gotson/komga/infrastructure/archive/PdfExtractor.kt | 2 +- .../db/migration/V20190907104615__reparse_pdf_files.sql | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 komga/src/main/resources/db/migration/V20190907104615__reparse_pdf_files.sql diff --git a/komga/build.gradle.kts b/komga/build.gradle.kts index 37e23fc7de..44e3926daf 100644 --- a/komga/build.gradle.kts +++ b/komga/build.gradle.kts @@ -19,7 +19,7 @@ plugins { } group = "org.gotson" -version = "0.3.0" +version = "0.3.1" repositories { jcenter() diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/archive/PdfExtractor.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/archive/PdfExtractor.kt index a01d2740ea..d079cb898d 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/archive/PdfExtractor.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/archive/PdfExtractor.kt @@ -19,7 +19,7 @@ class PdfExtractor : ArchiveExtractor() { override fun getPagesList(path: Path): List = PDDocument.load(Files.newInputStream(path)).use { pdf -> - (0..pdf.numberOfPages).map { index -> + (1..pdf.numberOfPages).map { index -> BookPage(index.toString(), mediaType) } } diff --git a/komga/src/main/resources/db/migration/V20190907104615__reparse_pdf_files.sql b/komga/src/main/resources/db/migration/V20190907104615__reparse_pdf_files.sql new file mode 100644 index 0000000000..c628ffd160 --- /dev/null +++ b/komga/src/main/resources/db/migration/V20190907104615__reparse_pdf_files.sql @@ -0,0 +1,5 @@ +update BOOK_METADATA +set STATUS = 'UNKNOWN' +where ID in ( + SELECT ID FROM BOOK_METADATA where MEDIA_TYPE = 'application/pdf' + ); \ No newline at end of file