mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB metadata: Fix deleting ISBN from EPUB file could result in an EPUB file without a package identifier if the ISBN was used as the package identifier. Fixes #1677383 [Embed Metadata plugin tool creating errors](https://bugs.launchpad.net/calibre/+bug/1677383)
This commit is contained in:
parent
14849c9005
commit
09fd203e87
@ -948,9 +948,23 @@ class OPF(object): # {{{
|
||||
return self.get_text(match) or None
|
||||
|
||||
def fset(self, val):
|
||||
uuid_id = None
|
||||
for attr in self.root.attrib:
|
||||
if attr.endswith('unique-identifier'):
|
||||
uuid_id = self.root.attrib[attr]
|
||||
break
|
||||
|
||||
matches = self.isbn_path(self.metadata)
|
||||
if not val:
|
||||
for x in matches:
|
||||
xid = x.get('id', None)
|
||||
is_package_identifier = uuid_id is not None and uuid_id == xid
|
||||
if is_package_identifier:
|
||||
self.set_text(x, str(uuid.uuid4()))
|
||||
for attr in x.attrib:
|
||||
if attr.endswith('scheme'):
|
||||
x.attrib[attr] = 'uuid'
|
||||
else:
|
||||
x.getparent().remove(x)
|
||||
return
|
||||
if not matches:
|
||||
|
Loading…
x
Reference in New Issue
Block a user