mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: When editing EPUB files, and a file is added in META-INF/ do not automatically add it to the manifest. Also do not warn about unmanifested files inside META-INF/ since a few vendors (Apple) require non standard files in that location. Fixes #1283015 [com.apple.ibooks.display-options.xml](https://bugs.launchpad.net/calibre/+bug/1283015)
This commit is contained in:
parent
2fa6a3b999
commit
32d347ea73
@ -98,20 +98,27 @@ class Unmanifested(BadLink):
|
|||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
BadLink.__init__(self, _(
|
BadLink.__init__(self, _(
|
||||||
'The file %s is not listed in the manifest') % name, name)
|
'The file %s is not listed in the manifest') % name, name)
|
||||||
if name == 'META-INF/calibre_bookmarks.txt':
|
|
||||||
self.HELP = _(
|
|
||||||
|
class Bookmarks(BadLink):
|
||||||
|
|
||||||
|
HELP = _(
|
||||||
'This file stores the bookmarks and last opened information from'
|
'This file stores the bookmarks and last opened information from'
|
||||||
' the calibre ebook viewer. You can remove it if you do not'
|
' the calibre ebook viewer. You can remove it if you do not'
|
||||||
' need that information, or dont want to share it with'
|
' need that information, or dont want to share it with'
|
||||||
' other people you send this book to.')
|
' other people you send this book to.')
|
||||||
self.INDIVIDUAL_FIX = _('Remove this file')
|
INDIVIDUAL_FIX = _('Remove this file')
|
||||||
self.level = INFO
|
level = INFO
|
||||||
self.msg = _('The bookmarks file used by the calibre ebook viewer is present')
|
|
||||||
|
def __init__(self, name):
|
||||||
|
BadLink.__init__(self, _(
|
||||||
|
'The bookmarks file used by the calibre ebook viewer is present'), name)
|
||||||
|
|
||||||
def __call__(self, container):
|
def __call__(self, container):
|
||||||
container.remove_item(self.name)
|
container.remove_item(self.name)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class MimetypeMismatch(BaseError):
|
class MimetypeMismatch(BaseError):
|
||||||
|
|
||||||
level = WARN
|
level = WARN
|
||||||
@ -243,7 +250,9 @@ def check_links(container):
|
|||||||
|
|
||||||
manifest_names = set(container.manifest_id_map.itervalues())
|
manifest_names = set(container.manifest_id_map.itervalues())
|
||||||
for name in container.mime_map:
|
for name in container.mime_map:
|
||||||
if name not in container.names_that_need_not_be_manifested and name not in manifest_names:
|
if name not in manifest_names and not container.ok_to_be_unmanifested(name):
|
||||||
a(Unmanifested(name))
|
a(Unmanifested(name))
|
||||||
|
if name == 'META-INF/calibre_bookmarks.txt':
|
||||||
|
a(Bookmarks(name))
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
|
@ -192,7 +192,7 @@ class Container(object): # {{{
|
|||||||
mt = media_type or self.guess_type(name)
|
mt = media_type or self.guess_type(name)
|
||||||
self.name_path_map[name] = path
|
self.name_path_map[name] = path
|
||||||
self.mime_map[name] = mt
|
self.mime_map[name] = mt
|
||||||
if name in self.names_that_need_not_be_manifested:
|
if self.ok_to_be_unmanifested(name):
|
||||||
return
|
return
|
||||||
all_ids = {x.get('id') for x in self.opf_xpath('//*[@id]')}
|
all_ids = {x.get('id') for x in self.opf_xpath('//*[@id]')}
|
||||||
c = 0
|
c = 0
|
||||||
@ -386,6 +386,9 @@ class Container(object): # {{{
|
|||||||
data, self.used_encoding = xml_to_unicode(data)
|
data, self.used_encoding = xml_to_unicode(data)
|
||||||
return fix_data(data)
|
return fix_data(data)
|
||||||
|
|
||||||
|
def ok_to_be_unmanifested(self, name):
|
||||||
|
return name in self.names_that_need_not_be_manifested
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def names_that_need_not_be_manifested(self):
|
def names_that_need_not_be_manifested(self):
|
||||||
return {self.opf_name}
|
return {self.opf_name}
|
||||||
@ -888,6 +891,9 @@ class EpubContainer(Container):
|
|||||||
def names_that_need_not_be_manifested(self):
|
def names_that_need_not_be_manifested(self):
|
||||||
return super(EpubContainer, self).names_that_need_not_be_manifested | {'META-INF/' + x for x in self.META_INF}
|
return super(EpubContainer, self).names_that_need_not_be_manifested | {'META-INF/' + x for x in self.META_INF}
|
||||||
|
|
||||||
|
def ok_to_be_unmanifested(self, name):
|
||||||
|
return name in self.names_that_need_not_be_manifested or name.startswith('META-INF/')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def names_that_must_not_be_removed(self):
|
def names_that_must_not_be_removed(self):
|
||||||
return super(EpubContainer, self).names_that_must_not_be_removed | {'META-INF/container.xml'}
|
return super(EpubContainer, self).names_that_must_not_be_removed | {'META-INF/container.xml'}
|
||||||
|
@ -339,7 +339,6 @@ class FileList(QTreeWidget):
|
|||||||
icon = self.rendered_emblem_cache[emblems] = canvas
|
icon = self.rendered_emblem_cache[emblems] = canvas
|
||||||
item.setData(0, Qt.DecorationRole, icon)
|
item.setData(0, Qt.DecorationRole, icon)
|
||||||
|
|
||||||
ok_to_be_unmanifested = container.names_that_need_not_be_manifested
|
|
||||||
cannot_be_renamed = container.names_that_must_not_be_changed
|
cannot_be_renamed = container.names_that_must_not_be_changed
|
||||||
ncx_mime = guess_type('a.ncx')
|
ncx_mime = guess_type('a.ncx')
|
||||||
|
|
||||||
@ -371,7 +370,7 @@ class FileList(QTreeWidget):
|
|||||||
if imt == ncx_mime:
|
if imt == ncx_mime:
|
||||||
emblems.append('toc.png')
|
emblems.append('toc.png')
|
||||||
tooltips.append(_('This file contains the metadata table of contents'))
|
tooltips.append(_('This file contains the metadata table of contents'))
|
||||||
if name not in manifested_names and name not in ok_to_be_unmanifested:
|
if name not in manifested_names and not container.ok_to_be_unmanifested(name):
|
||||||
emblems.append('dialog_question.png')
|
emblems.append('dialog_question.png')
|
||||||
tooltips.append(_('This file is not listed in the book manifest'))
|
tooltips.append(_('This file is not listed in the book manifest'))
|
||||||
if linear is False:
|
if linear is False:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user