pdf/processing: avoid possible dead goblin if pdfinfo failed
authorAlon Levy <alon@pobox.com>
Fri, 27 Dec 2013 00:34:40 +0000 (18:34 -0600)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 27 Dec 2013 00:34:40 +0000 (18:34 -0600)
mediagoblin/media_types/pdf/processing.py

index 6fb0b78295a6385d269198c047c4dd951538f9b6..4dd894d849c85121ec1ab11a46def6e6f070e0c8 100644 (file)
@@ -210,6 +210,11 @@ def pdf_info(original):
     info_dict = dict([[part.strip() for part in l.strip().split(':', 1)]
                       for l in lines if ':' in l])
 
+    if 'Page size' not in info_dict.keys():
+        # TODO - message is for the user, not debug, but BadMediaFail not taking an argument, fix that.
+        _log.debug('Missing "Page size" key in returned pdf - conversion failed?')
+        raise BadMediaFail()
+
     for date_key in [('pdf_mod_date', 'ModDate'),
                      ('pdf_creation_date', 'CreationDate')]:
         if date_key in info_dict: