Project

General

Profile

Deleted recordings not removed from filesystem

Added by Davor Komljenovic over 7 years ago

Hello,

I am not sure if this is a Tvheadend problem, Kodi problem, or my NAS problem. I am hoping somebody can give me a simple answer.

I am running 4.1-2413~g489ba95 on a Odroid XU4 and Debian Jessie headless server. I am running Kodi 16.1 (LibreELEC 7.0.2) on Cubox. I have a Seagate Personal Cloud NAS which is mounted in the tvheadend machine with read/write access. This is where my recordings are stored.

The issue I have is that some (but not all) recordings that I deleted using Recordings tab in Kodi are not actually removed from the NAS. I noticed that there were multiple files on the folder where recordings are stored with file extension ".removing". These are some of the recordings that I deleted from Kodi. Now I monitored what was happening in Tvheadend and the NAS folder when I was deleting some recordings. Yesterday I deleted four recordings, all in the same folder on the NAS folder. One recording was not deleted but just changed the extension from ".ts" to ".ts.removing". The other three recordings were actually removed.

So I don't know if Tvheadend is doing this, Kodi is causing problems or is this some default NAS behavior that it just changes the extension and removes it eventually. What bothered me is that I saw recordings that were deleted in November 2016 but were still on the NAS.

So, any thoughts? I guess if the developers know that Tvheadend code never changes the extension of the file then I know it must be the NAS. Thanks ahead.


Replies (10)

RE: Deleted recordings not removed from filesystem - Added by Steffen Wagner over 7 years ago

Same issue here.

The file is renamed by tvheadend. [[https://github.com/tvheadend/tvheadend/blob/master/src/utils.c#L712]]
There is a function "deferred_unlink", so it seems, that tvheadend is not able to delete the file on request.

In my experience this will happen, if i delete a recording (maybe in Kodi) while it's still playing or a postprocess is still running on it.
I think, it's a good Feature to do so, but what we need is a cleanup afterwards automaticly.

RE: Deleted recordings not removed from filesystem - Added by Davor Komljenovic over 7 years ago

Steffen,

Thank you for this info. Now I know it is Tvheadend. Hmm, it could be that some process is still going on with the file and that is preventing the file from being deleted. For example, my wife has a habit of deleting the recording while it is still playing.

I guess there is no cleanup by Tvheadend? Could be a nice feature to implement, deleting the ".removing" files later, maybe 24 hours later or by some schedule.

RE: Deleted recordings not removed from filesystem - Added by Steffen Wagner over 7 years ago

Davor Komljenovic wrote:

... For example, my wife has a habit of deleting the recording while it is still playing. ...

Again, same "issue" here :-)

Currently, i don't know about a existing cleanup (but i'm fairly new using tvheadend).
Indeed, it should be implemented.

RE: Deleted recordings not removed from filesystem - Added by Arne Hein almost 6 years ago

Hi guys,

I have the same issue. Did you find a solution for this?

Cheers

RE: Deleted recordings not removed from filesystem - Added by Davor Komljenovic almost 6 years ago

Arne,

I found no solution in Tvheadend for this. What I did was tell my wife to always first stop the playback of the recording then delete it in Kodi.

However, I am now running a much newer version of Tvheadend so maybe a clean up of the deleted recordings was implemented. I have not tested it recently. Maybe someone from development can quickly say whether something was implemented to fix this.

RE: Deleted recordings not removed from filesystem - Added by Em Smith almost 6 years ago

I'm not sure why you're all deleting the shows while you are trying to watch them.

The problem is likely your NAS. Some filesystems (mostly Windows ones, probably also samba shared ones) don't allow you to delete open files. So you probably have an error logged in tvh saying it could not delete the file. Some other old filesystem are slow to delete very large files. So, the file is renamed and then asap it is deleted in another thread so we don't block the main processing waiting for the file to be deleted.

The dev branch of tvh has an option in Config->Recording->DVR Profile called "Automatically delete played recordings" (possibly hidden in expert settings). Set that to "2 days" and the programmes you have played will be automatically deleted without you having to manually mess around with deleting recordings. You have to watch the programme through to the end though, so if you have a large over-record you need to just skip to the end by pressing "up" in Kodi to do a big skip.

RE: Deleted recordings not removed from filesystem - Added by Arne Hein almost 6 years ago

Hi guys,

thank you for the answers.
Sorry, for me it's slightly different, but I guess it leads to the same issue.
I'm not deleting anything while I'm watching it, but some items I'm deleting are not deleted correctly. The space shwon in Kodi stays the same.
Strangly this works for the most items, but especially HD items with greater size doesn't work. They disappear in Kodi, but the available space is not being updated.

Any ideas on this?

Thank you! :)

RE: Deleted recordings not removed from filesystem - Added by Em Smith almost 6 years ago

I'm not sure why large items aren't deleted for you. Any errors logged? You should see "unable to remove XXXX". What filesystem are you using? (ext2,3,4, ntfs, zfs, btrfs, etc.?) Is it local or mounted via samba or nfs?

RE: Deleted recordings not removed from filesystem - Added by Arne Hein almost 6 years ago

Hi Em,

thank you for your answer.
I have mounted my NAS (WDMyCloud) via nfs. I need to check the error log again on TvHeadend. In Kodi it looks good.

Br Arne

RE: Deleted recordings not removed from filesystem - Added by Em Smith almost 6 years ago

I was looking at info about the WDMyCloud and (if you've not done it) I'd advise you to upgrade the OS on that NAS for security reasons [[https://www.theregister.co.uk/2018/01/08/wd_mycloud_nas_backdoor/]]

It's very strange to have files lying around since the way NFS deletes open files is to rename them to ".nfsXXXX" until they are no longer open. (I know you're not deleting when open, but just for reference for others with the same NAS who are doing such things).

So, can you see the files on the disk after they are deleted?

Say you have your files in "/net/nas/tvrec" you could do something like (when the system is quiet so not recording):

find /net/nas/tvrec -ls | sort > /tmp/pre

++++delete file however you are doing it++++

find /net/nas/tvrec -ls | sort > /tmp/post

diff /tmp/pre /tmp/post

This creates a list of files before removing and after removing then do a "difference" of the files. The diff should just list any files that are different due to being deleted, renamed, etc. If there is nothing different then something is wrong (since file should be removed).

    (1-10/10)