Catalogs: Do not erase any tags the user adds to a catalog book entry when the catalog is re-generated. Fixes #1262875 [Enhancement request: Ability to customize epub catalogue tag](https://bugs.launchpad.net/calibre/+bug/1262875)

This commit is contained in:
Kovid Goyal 2023-11-13 16:38:12 +05:30
parent 416237a2a5
commit 049253f8d7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -256,18 +256,20 @@ def add_catalog(cache, path, title, dbapi=None):
try:
mi = get_metadata(stream, fmt)
mi.authors = ['calibre']
except:
except Exception:
mi = Metadata(title, ['calibre'])
mi.title, mi.authors = title, ['calibre']
mi.author_sort = 'calibre' # The MOBI/AZW3 format sets author sort to date
mi.tags = [_('Catalog')]
mi.pubdate = mi.timestamp = utcnow()
if fmt == 'mobi':
mi.cover, mi.cover_data = None, (None, None)
if db_id is None:
mi.tags = [_('Catalog')]
db_id = cache._create_book_entry(mi, apply_import_tags=False)
new_book_added = True
else:
if not mi.tags or _('Catalog') not in mi.tags:
mi.tags.append(_('Catalog'))
cache._set_metadata(db_id, mi)
cache.add_format(db_id, fmt, stream, dbapi=dbapi) # Can't keep write lock since post-import hooks might run