From 58b2b5634b2d37e899c92250eda817837f74a601 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Sun, 29 Sep 2024 17:40:20 +0100 Subject: [PATCH] Ensure that mi.deepcopy_metadata() keeps the top-level attributes 'id' and 'has_cover' --- src/calibre/ebooks/metadata/book/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/ebooks/metadata/book/base.py b/src/calibre/ebooks/metadata/book/base.py index 0376584242..ce90dc92de 100644 --- a/src/calibre/ebooks/metadata/book/base.py +++ b/src/calibre/ebooks/metadata/book/base.py @@ -231,6 +231,9 @@ class Metadata: # are returning a "real" Metadata instance that has __get_attribute__. m = Metadata(None) object.__setattr__(m, '_data', copy.deepcopy(object.__getattribute__(self, '_data'))) + # Also copy these two top-level attributes as they can appear in templates. + object.__setattr__(m, 'id', copy.copy(self.get('id'))) + object.__setattr__(m, 'has_cover', copy.copy(self.get('has_cover'))) return m def get(self, field, default=None):