=================================================================== RCS file: /cvs/openbsd/OpenBSDTorrents/CurrentTorrents.pl,v retrieving revision 1.8 retrieving revision 1.12 diff -u -r1.8 -r1.12 --- openbsd/OpenBSDTorrents/CurrentTorrents.pl 2005/03/31 01:14:58 1.8 +++ openbsd/OpenBSDTorrents/CurrentTorrents.pl 2005/05/02 21:27:00 1.12 @@ -1,5 +1,5 @@ #!/usr/bin/perl -T -#$Id: CurrentTorrents.pl,v 1.8 2005/03/31 01:14:58 andrew Exp $ +#$Id: CurrentTorrents.pl,v 1.12 2005/05/02 20:27:00 andrew Exp $ use strict; use warnings; use diagnostics; @@ -7,7 +7,7 @@ use BT::MetaInfo; use Time::Local; -use lib '/usr/local/bin/OpenBSDTorrents/lib'; +use lib 'lib'; use OpenBSDTorrents; %ENV = (); @@ -16,8 +16,16 @@ justme(); +my $Name_Filter = shift || ''; +if ($Name_Filter =~ /^(\w*)$/) { + $Name_Filter = $1; +} else { + die "Invalid filter: $Name_Filter"; +} + my %files; -opendir DIR, $TorrentDir or die "Couldn't opendir $TorrentDir: $!"; +opendir DIR, $OBT->{DIR_TORRENT} + or die "Couldn't opendir $OBT->{DIR_TORRENT}: $!"; foreach (readdir DIR) { if (/^([^\/]+)$/) { $_ = $1; @@ -49,14 +57,15 @@ my %keep; my @delete; foreach my $name (keys %files) { - #print "$name\n"; + next unless $name =~ /^$Name_Filter/; + print "Checking $name\n"; foreach my $epoch ( sort { $b <=> $a } keys %{ $files{$name} } ) { #print "\t$epoch\n"; my $torrent = $files{$name}{$epoch}{file}; my $t; - eval { $t = BT::MetaInfo->new("$TorrentDir/$torrent"); }; + eval { $t = BT::MetaInfo->new($OBT->{DIR_TORRENT} . "/$torrent"); }; if ($@) { warn "Error reading torrent $torrent\n"; next; @@ -65,7 +74,7 @@ $files{$name}{$epoch}{comment} = $t->{comment}; my ($path) = $t->{comment} =~ /Files from ([^\n]+)\n/s; - unless (-d "$BaseDir/$path") { + unless (-d $OBT->{DIR_FTP} . "/$path") { #print "Deleting $files{$name}{$epoch}{file} the path doesn't exist.\n"; push @delete, $files{$name}{$epoch}{file}; } @@ -102,5 +111,5 @@ foreach (@delete) { print "Deleting '$_'\n"; - unlink "$TorrentDir/$_" or die "Couldn't unlink $_"; + unlink $OBT->{DIR_TORRENT} . "/$_" or die "Couldn't unlink $_"; }