=================================================================== RCS file: /cvs/openbsd/OpenBSDTorrents/CurrentTorrents.pl,v retrieving revision 1.4 retrieving revision 1.11 diff -u -r1.4 -r1.11 --- openbsd/OpenBSDTorrents/CurrentTorrents.pl 2005/03/24 00:20:33 1.4 +++ openbsd/OpenBSDTorrents/CurrentTorrents.pl 2005/04/07 00:04:40 1.11 @@ -1,5 +1,5 @@ #!/usr/bin/perl -T -#$Id: CurrentTorrents.pl,v 1.4 2005/03/24 00:20:33 andrew Exp $ +#$Id: CurrentTorrents.pl,v 1.11 2005/04/06 23:04:40 andrew Exp $ use strict; use warnings; use diagnostics; @@ -14,8 +14,11 @@ #use YAML; +justme(); + 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; @@ -26,9 +29,10 @@ my ($name, $year, $mon, $mday, $hour, $min) = /^(.*)-(\d{4})-(\d{2})-(\d{2})-(\d{2})(\d{2})/; + $mon--; my $epoch = timegm(0,$min,$hour,$mday,$mon,$year); - print "Adding $_\n"; + #print "Adding $_\n"; $files{$name}{$epoch} = { file => $_, @@ -53,7 +57,7 @@ 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; @@ -62,13 +66,13 @@ $files{$name}{$epoch}{comment} = $t->{comment}; my ($path) = $t->{comment} =~ /Files from ([^\n]+)\n/s; - unless (-d "$TorrentDir/$path") { - print "Deleting $files{$name}{$epoch}{file} the path doesn't exist.\n"; + unless (-d $OBT->{DIR_FTP} . "/$path") { + #print "Deleting $files{$name}{$epoch}{file} the path doesn't exist.\n"; push @delete, $files{$name}{$epoch}{file}; } if (keys %{ $files{$name} } == 1) { - print "Skipping torrent for $name there is only one.\n"; + #print "Skipping torrent for $name there is only one.\n"; next; } @@ -99,5 +103,5 @@ foreach (@delete) { print "Deleting '$_'\n"; - unlink "$TorrentDir/$_" or die "Couldn't unlink $_"; + unlink $OBT->{DIR_TORRENT} . "/$_" or die "Couldn't unlink $_"; }