From 9b1f715e62fc326c14d94835e4e614ad9fc9709b Mon Sep 17 00:00:00 2001 From: "E.Smith" <31170571+azlm8t@users.noreply.github.com> Date: Sun, 23 Sep 2018 10:13:12 +0100 Subject: [PATCH] dvr: Persist dvr entry filename upon creation. 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index 43880a426..99591ceda 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -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; -- 2.47.3