Skip to content

Commit

Permalink
When adding new books if the timestamp is specified as undefined use …
Browse files Browse the repository at this point in the history
…the current timestamp. Fixes #2069494 ['Sometimes' timestamp column has incorrect data](https://bugs.launchpad.net/calibre/+bug/2069494)
  • Loading branch information
kovidgoyal committed Jun 15, 2024
1 parent 8f7b330 commit dcc2078
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/calibre/db/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from calibre.ebooks.metadata.opf2 import metadata_to_opf
from calibre.ptempfile import PersistentTemporaryFile, SpooledTemporaryFile, base_dir
from calibre.utils.config import prefs, tweaks
from calibre.utils.date import UNDEFINED_DATE, timestampfromdt, utcnow
from calibre.utils.date import UNDEFINED_DATE, is_date_undefined, timestampfromdt, utcnow
from calibre.utils.date import now as nowf
from calibre.utils.filenames import make_long_path_useable
from calibre.utils.icu import lower as icu_lower
Expand Down Expand Up @@ -2146,7 +2146,7 @@ def create_book_entry(self, mi, cover=None, add_duplicates=True, force_id=None,
book_id = self.backend.last_insert_rowid()
self.event_dispatcher(EventType.book_created, book_id)

mi.timestamp = utcnow() if mi.timestamp is None else mi.timestamp
mi.timestamp = utcnow() if (mi.timestamp is None or is_date_undefined(mi.timestamp)) else mi.timestamp
mi.pubdate = UNDEFINED_DATE if mi.pubdate is None else mi.pubdate
if cover is not None:
mi.cover, mi.cover_data = None, (None, cover)
Expand Down

0 comments on commit dcc2078

Please sign in to comment.