From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Fri, 21 Sep 2018 17:23:31 +0000 (+0100) Subject: dvr: Fake create timestamp for old dvr entries. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da2e49c9c78ca355eaa2531f104083ef4b37d8c7;p=thirdparty%2Ftvheadend.git dvr: Fake create timestamp for old dvr entries. 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). --- diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index f6200629a..4fb3d6b93 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -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 */