]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
dvr: Fake create timestamp for old dvr entries.
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Fri, 21 Sep 2018 17:23:31 +0000 (18:23 +0100)
committerperexg <perex@perex.cz>
Wed, 26 Sep 2018 15:30:47 +0000 (17:30 +0200)
Old dvr_entry records (tvh4.2) do not have a create timestamp, so we
fake one based on the start time of the recording. This will allow
us to send the timestamp to the UI in the future knowing that it
will give consistent results for user sorting since it may be
useful for user to sort upcoming recordings by when they were
created (i.e., scheduled).

src/dvr/dvr_db.c

index f6200629ae5b1f896277c85f47b87f1c139e5a91..4fb3d6b930b6f5097e0310316d0dd63e79c2d8ed 100644 (file)
@@ -947,7 +947,7 @@ dvr_entry_t *
 dvr_entry_create(const char *uuid, htsmsg_t *conf, int clone)
 {
   dvr_entry_t *de, *de2;
-  int64_t start, stop, create;
+  int64_t start, stop, create, now;
   htsmsg_t *m;
   char ubuf[UUID_HEX_SIZE], ubuf2[UUID_HEX_SIZE];
   const char *s;
@@ -983,7 +983,19 @@ dvr_entry_create(const char *uuid, htsmsg_t *conf, int clone)
   if (!htsmsg_get_s64(conf, "create", &create)) {
       de->de_create = create;
   } else {
-      de->de_create = time(NULL);
+      /* Old dvr entry without a create time, so fake one.  For
+       * entries that are older than a day, assume these are old
+       * (tvh4.2) recordings, so use the start time as the create
+       * time. This will allow user to order records by create time
+       * and get something reasonable. For all new records however, we
+       * use now since they will be written to disk.
+       */
+      now = time(NULL);
+      if (now > start && start < now - 86400)
+          create = start;
+      else
+          create = now;
+      de->de_create = create;
   }
 
   /* Extract episode info */