Skip to content

Commit

Permalink
Only copy has_cover and id if they exist
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Sep 29, 2024
1 parent c10a718 commit 5b17a24
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/calibre/ebooks/metadata/book/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import copy
import traceback
from contextlib import suppress

from calibre import prints
from calibre.constants import DEBUG
Expand Down Expand Up @@ -232,8 +233,10 @@ def deepcopy_metadata(self):
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')))
with suppress(AttributeError):
object.__setattr__(m, 'id', copy.copy(self.__getattribute__('id')))
with suppress(AttributeError):
object.__setattr__(m, 'has_cover', copy.copy(self.__getattribute__('has_cover')))
return m

def get(self, field, default=None):
Expand Down

0 comments on commit 5b17a24

Please sign in to comment.