[mythtv-users] find orphans.py question

Raymond Wagner raymond at wagnerrp.com
Wed Apr 13 19:06:44 UTC 2011


On 4/13/2011 14:41, Warpme wrote:
> use DBI;

You should be using the MythTV module, rather than direct database 
access.  It will read the necessary config files to find the database, 
and fall back to UPnP detection if the config files do not exist.

> &dir_lookup("SELECT data FROM settings WHERE value='RecordFilePrefix' 
> AND hostname=(?)");

This hasn't been used since 0.19.  Does it still need checking?

> my $q = "SELECT title, subtitle, description, starttime, endtime, 
> chanid, basename FROM recorded WHERE hostname=(?) 

Limiting yourself to a specific hostname can be dangerous.  In 
situations with multiple backends using shared storage, one backend 
would see recordings from another as an orphaned file.

>             my $sql = sprintf "DELETE FROM oldrecorded WHERE title 
> LIKE \"%s\" AND subtitle LIKE \"%s\" AND description LIKE \"%s\" LIMIT 
> 1", $title, $subtitle, $description;
>             my $sql = sprintf "DELETE FROM recorded WHERE basename 
> LIKE \"%s\" LIMIT 1",$basename;
>                 my $sql = sprintf "UPDATE oldrecorded SET duplicate = 
> 0 where title = \"%s\" and starttime = \"%s\" and chanid = \"%s\"",

You should be using MythProto calls for all of these.  There is a 
_whole_ lot more to removing a recording from the database than just 
removing its entry in `recorded`.  All of these should be accompanied by 
a call to rerun the scheduler.

>                         unlink "$this_dir/$this_file";

Again, you should be using MythProto calls for this.  Unlinking a file 
on an ext3 filesystem has some serious implications, and can result in 
the damaging of in-progress recordings.  Using the MythProto call to 
delete the file will allow it to follow the slow delete setting.


More information about the mythtv-users mailing list