mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 04:52:48 +02:00
Fix updating the calibre application id in EPUBs that also use the application id as the package id.
This commit is contained in:
parent
6fc800d6c6
commit
be977db0d9
1 changed files with 10 additions and 0 deletions
|
|
@ -941,9 +941,19 @@ def fget(self):
|
|||
return self.get_text(match) or None
|
||||
|
||||
def fset(self, val):
|
||||
removed_ids = set()
|
||||
for x in tuple(self.application_id_path(self.metadata)):
|
||||
removed_ids.add(x.get('id', None))
|
||||
x.getparent().remove(x)
|
||||
|
||||
uuid_id = None
|
||||
for attr in self.root.attrib:
|
||||
if attr.endswith('unique-identifier'):
|
||||
uuid_id = self.root.attrib[attr]
|
||||
break
|
||||
attrib = {'{%s}scheme'%self.NAMESPACES['opf']: 'calibre'}
|
||||
if uuid_id and uuid_id in removed_ids:
|
||||
attrib['id'] = uuid_id
|
||||
self.set_text(self.create_metadata_element(
|
||||
'identifier', attrib=attrib), unicode(val))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue