From 4c68fafd41057cc6ae4df975ae8c9b1a0ce9209a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 14 Nov 2023 21:45:26 +0530 Subject: [PATCH] Fix catalog tags not being preserved --- src/calibre/db/adding.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/db/adding.py b/src/calibre/db/adding.py index 6acd635196..749983681d 100644 --- a/src/calibre/db/adding.py +++ b/src/calibre/db/adding.py @@ -268,8 +268,10 @@ def add_catalog(cache, path, title, dbapi=None): 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')) + tags = list(cache._field_for('tags', db_id) or ()) + if _('Catalog') not in tags: + tags.append(_('Catalog')) + mi.tags = tags 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