]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
dvr: Persist dvr entry filename upon creation.
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Sun, 23 Sep 2018 09:13:12 +0000 (10:13 +0100)
committerperexg <perex@perex.cz>
Wed, 26 Sep 2018 15:37:57 +0000 (17:37 +0200)
Previously we added the filename to the dvr_entry at the start of the
recording, but did not persist it. This meant that if tvheadend
crashed before the programme completed then we would leave a file on
disk which is not referenced by any recording, hence will never be
deleted.

So we persist after the file is created/stream opened. This entry then
has filename, stream info, and (actual) start time, but no (actual)
stop time.

src/dvr/dvr_rec.c

index 43880a4265a9c07b4d0a8305d7bf5960c2871f69..99591ceda6815912bc2d615481157b56fe898892 100644 (file)
@@ -1483,6 +1483,11 @@ dvr_thread_rec_start(dvr_entry_t **_de, streaming_start_t *ss,
       return 0;
     dvr_rec_set_state(de, DVR_RS_WAIT_PROGRAM_START, 0);
     int code = dvr_rec_start(de, ss);
+    /* Persist entry so we save the filename details to avoid orphan
+     * files if we crash before the programme completes recording.
+     */
+    dvr_entry_changed(de);
+    htsp_dvr_entry_update(de);
     if(code == 0) {
       ret = 1;
       *started = 1;