Bug #4635
DVR log doesn't track files if it crashes during recording
0%
Description
It seems that filename information is only recorded in the dvr/log after the recording completes rather than when it starts.
However, this means that if Tvheadend crashes during recording then we lose track of the files to which we are writing and means they never get deleted.
For example I have a recorded filename bob.ts, <crash> and then bob-1.ts but only bob-1.ts is in any file in dvr/log. I expect both bob.ts and bob-1.ts in the same entry in the dvr/log.
History
Updated by Em Smith about 7 years ago
Assuming the user has a normal environment (not some cut-down environment where tools don't quite work) then the following will show files that exist in the recording directory (assumed to be /media/recordings) but do not exist in the dvr log files:
cd ~hts/.hts/tvheadend/dvr/log; find /media/recordings/ -type f | grep -v -f <(grep \"filename\": * | awk -F\" '{print $4}' | xargs -d'\n' realpath) |& grep -v -e jpg$ -e nfo$ -e txt$
The "realpath" is there because I have some symlinks as mount points have moved around, and the final grep is to remove common clutter that may be created such as images, nfo files or cut lists.
I couldn't use "jq" since a few of my files contained invalid characters in parent/child such as:
"parent": "<C0>^H"
and
"child": "<C0>^H",
and this prevented parsing.
I think the child/parent accessors should use prop_sbuf, but since I don't know how they are used I haven't made the change.
Updated by Jaroslav Kysela about 7 years ago
Em Smith wrote:
I think the child/parent accessors should use prop_sbuf, but since I don't know how they are used I haven't made the change.
Good point. The problem is even worse (modification of prop_sbuf_ptr which should not be touched at all). Fixes in https://tvheadend.org/projects/tvheadend/repository/revisions/ffb2932c5c8ab7cc3d5fcc7a28960194f4fc938e .