From dcc207867598841a0bb79c4ab1d6c59edcd2732a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 15 Jun 2024 16:50:49 +0530 Subject: [PATCH] When adding new books if the timestamp is specified as undefined use the current timestamp. Fixes #2069494 ['Sometimes' timestamp column has incorrect data](https://bugs.launchpad.net/calibre/+bug/2069494) --- src/calibre/db/cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index aae4e85de0..e84b8b138d 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -45,7 +45,7 @@ from calibre.ebooks.metadata.book.base import Metadata 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 @@ -2146,7 +2146,7 @@ class Cache: 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)