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):
|
||||
BadLink.__init__(self, _(
|
||||
'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'
|
||||
' the calibre ebook viewer. You can remove it if you do not'
|
||||
' need that information, or dont want to share it with'
|
||||
' other people you send this book to.')
|
||||
self.INDIVIDUAL_FIX = _('Remove this file')
|
||||
self.level = INFO
|
||||
self.msg = _('The bookmarks file used by the calibre ebook viewer is present')
|
||||
INDIVIDUAL_FIX = _('Remove this file')
|
||||
level = INFO
|
||||
|
||||
def __init__(self, name):
|
||||
BadLink.__init__(self, _(
|
||||
'The bookmarks file used by the calibre ebook viewer is present'), name)
|
||||
|
||||
def __call__(self, container):
|
||||
container.remove_item(self.name)
|
||||
return True
|
||||
|
||||
|
||||
class MimetypeMismatch(BaseError):
|
||||
|
||||
level = WARN
|
||||
@ -243,7 +250,9 @@ def check_links(container):
|
||||
|
||||
manifest_names = set(container.manifest_id_map.itervalues())
|
||||
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))
|
||||
if name == 'META-INF/calibre_bookmarks.txt':
|
||||
a(Bookmarks(name))
|
||||
|
||||
return errors
|
||||
|
@ -192,7 +192,7 @@ class Container(object): # {{{
|
||||
mt = media_type or self.guess_type(name)
|
||||
self.name_path_map[name] = path
|
||||
self.mime_map[name] = mt
|
||||
if name in self.names_that_need_not_be_manifested:
|
||||
if self.ok_to_be_unmanifested(name):
|
||||
return
|
||||
all_ids = {x.get('id') for x in self.opf_xpath('//*[@id]')}
|
||||
c = 0
|
||||
@ -386,6 +386,9 @@ class Container(object): # {{{
|
||||
data, self.used_encoding = xml_to_unicode(data)
|
||||
return fix_data(data)
|
||||
|
||||
def ok_to_be_unmanifested(self, name):
|
||||
return name in self.names_that_need_not_be_manifested
|
||||
|
||||
@property
|
||||
def names_that_need_not_be_manifested(self):
|
||||
return {self.opf_name}
|
||||
@ -888,6 +891,9 @@ class EpubContainer(Container):
|
||||
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}
|
||||
|
||||
def ok_to_be_unmanifested(self, name):
|
||||
return name in self.names_that_need_not_be_manifested or name.startswith('META-INF/')
|
||||
|
||||
@property
|
||||
def names_that_must_not_be_removed(self):
|
||||
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
|
||||
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
|
||||
ncx_mime = guess_type('a.ncx')
|
||||
|
||||
@ -371,7 +370,7 @@ class FileList(QTreeWidget):
|
||||
if imt == ncx_mime:
|
||||
emblems.append('toc.png')
|
||||
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')
|
||||
tooltips.append(_('This file is not listed in the book manifest'))
|
||||
if linear is False:
|
||||
|
Loading…
x
Reference in New Issue
Block a user