mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Nicer error message when failing to edit EPUB file with missing obfuscation key
This commit is contained in:
parent
a2d99fd452
commit
0cd76baa1b
@ -893,6 +893,9 @@ class Container(object): # {{{
|
||||
class InvalidEpub(InvalidBook):
|
||||
pass
|
||||
|
||||
class ObfuscationKeyMissing(InvalidEpub):
|
||||
pass
|
||||
|
||||
OCF_NS = 'urn:oasis:names:tc:opendocument:xmlns:container'
|
||||
|
||||
class EpubContainer(Container):
|
||||
@ -1071,7 +1074,7 @@ class EpubContainer(Container):
|
||||
for font, alg in fonts.iteritems():
|
||||
tkey = key if alg == ADOBE_OBFUSCATION else idpf_key
|
||||
if not tkey:
|
||||
raise InvalidBook('Failed to find obfuscation key')
|
||||
raise ObfuscationKeyMissing('Failed to find obfuscation key')
|
||||
raw = self.raw_data(font, decode=False)
|
||||
raw = decrypt_font_data(tkey, raw, alg)
|
||||
with self.open(font, 'wb') as f:
|
||||
|
@ -256,6 +256,11 @@ class Boss(QObject):
|
||||
if 'DRMError:' in job.traceback:
|
||||
from calibre.gui2.dialogs.drm_error import DRMErrorMessage
|
||||
return DRMErrorMessage(self.gui).exec_()
|
||||
if 'ObfuscationKeyMissing:' in job.traceback:
|
||||
return error_dialog(self.gui, _('Failed to open book'), _(
|
||||
'Failed to open book, it has obfuscated fonts, but the obfuscation key is missing from the OPF.'
|
||||
' Do an EPUB to EPUB conversion before trying to edit this book.'), show=True)
|
||||
|
||||
return error_dialog(self.gui, _('Failed to open book'),
|
||||
_('Failed to open book, click Show details for more information.'),
|
||||
det_msg=job.traceback, show=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user