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:
Kovid Goyal 2017-03-31 09:16:22 +05:30
parent 14849c9005
commit 09fd203e87

View File

@ -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: