When merging metadata objects, if a custom column has type multiple in the new data and some other type in the old data, ignore the old data instead of erroring out. Fixes #1881796 [Private bug](https://bugs.launchpad.net/calibre/+bug/1881796)

This commit is contained in:
Kovid Goyal 2020-06-04 07:54:47 +05:30
parent 0ce941104d
commit e0e0714426
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -15,7 +15,7 @@ from calibre.ebooks.metadata.book import (SC_COPYABLE_FIELDS,
TOP_LEVEL_IDENTIFIERS, ALL_METADATA_FIELDS) TOP_LEVEL_IDENTIFIERS, ALL_METADATA_FIELDS)
from calibre.library.field_metadata import FieldMetadata from calibre.library.field_metadata import FieldMetadata
from calibre.utils.icu import sort_key from calibre.utils.icu import sort_key
from polyglot.builtins import iteritems, unicode_type, filter, map from polyglot.builtins import iteritems, unicode_type, filter, map, string_or_bytes
# Special sets used to optimize the performance of getting and setting # Special sets used to optimize the performance of getting and setting
# attributes on Metadata objects # attributes on Metadata objects
@ -544,6 +544,8 @@ class Metadata(object):
meta = other.get_user_metadata(x, make_copy=True) meta = other.get_user_metadata(x, make_copy=True)
if meta is not None: if meta is not None:
self_tags = self.get(x, []) self_tags = self.get(x, [])
if isinstance(self_tags, string_or_bytes):
self_tags = []
self.set_user_metadata(x, meta) # get... did the deepcopy self.set_user_metadata(x, meta) # get... did the deepcopy
other_tags = other.get(x, []) other_tags = other.get(x, [])
if meta['datatype'] == 'text' and meta['is_multiple']: if meta['datatype'] == 'text' and meta['is_multiple']: