From 454bded053df5b29e5082f187437d302f638940b Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Sat, 12 Apr 2025 21:10:07 +0200
Subject: [PATCH] =?UTF-8?q?Zpracov=C3=A1n=C3=AD=20sken=C5=AF:=20Work-aroun?=
 =?UTF-8?q?d=20na=20Popplera=20u=C5=BE=20nen=C3=AD=20pot=C5=99eba?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 mo/jobs/protocols.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mo/jobs/protocols.py b/mo/jobs/protocols.py
index 0577ce48..cff9c948 100644
--- a/mo/jobs/protocols.py
+++ b/mo/jobs/protocols.py
@@ -357,11 +357,11 @@ def _process_scan_file(args: ScanJobArgs) -> ScanJobResult:
 
     res = ScanJobResult()
     logger.debug(f'Scan: Analyzuji soubor {args.in_path}')
-    pdf = poppler.load_from_file(args.in_path)
-    if not pdf._document:
-        # XXX: Poppler neumí hlásit chybu při otevírání dokumentu (https://github.com/cbrunet/python-poppler/issues/48)
-        # Tak zatím saháme dovnitř a detekujeme si ji sami.
-        res.error = 'Soubor není ve formátu PDF'
+    try:
+        pdf = poppler.load_from_file(args.in_path)
+    except ValueError:
+        logger.warning('Scan: Poppler ohlásil chybu při otevírání')
+        res.error = 'Soubor není ve formátu PDF nebo je poškozený'
         return res
 
     renderer = poppler.PageRenderer()
-- 
GitLab