=================================================================== RCS file: /cvs/openbsd/OpenBSDTorrents/ServerTorrents.pl,v retrieving revision 1.28 retrieving revision 1.30 diff -u -r1.28 -r1.30 --- openbsd/OpenBSDTorrents/ServerTorrents.pl 2010/01/07 18:50:02 1.28 +++ openbsd/OpenBSDTorrents/ServerTorrents.pl 2011/12/08 02:08:09 1.30 @@ -1,5 +1,5 @@ #!/usr/bin/perl -T -#$RedRiver: ServerTorrents.pl,v 1.27 2008/12/29 22:04:00 andrew Exp $ +#$RedRiver: ServerTorrents.pl,v 1.29 2010/03/08 20:19:37 andrew Exp $ use strict; use warnings; use diagnostics; @@ -99,6 +99,9 @@ if ( !exists $server_torrents{$hash} ) { Upload_Torrent( $torrents{$hash} ); } + elsif ( $server_torrents{$hash}{disabled} ) { + Update_Torrent( $server_torrents{$hash}{name}, $hash ); + } } closedir DIR; @@ -111,7 +114,7 @@ if ( ( !exists $torrents{$hash} ) && ( !$server_torrents{$hash}{disabled} ) ) { - Delete_Torrent( $server_torrents{$hash}{name}, $hash ); + Update_Torrent( $server_torrents{$hash}{name}, $hash, 1 ); } } @@ -122,7 +125,7 @@ my $t = $torrent->{'details'}; my $file = $torrent->{'file'}; - print "Uploading $file\n"; + #print "Uploading $file\n"; my $size = $t->total_size; my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday ) @@ -185,28 +188,31 @@ } } -sub Delete_Torrent { +sub Update_Torrent { my $filename = shift; my $hash = shift; + my $disable = shift || 0; die "No hash passed!" unless $hash; - print "Removing $filename [$hash]\n"; + #print "Removing $filename [$hash]\n"; my $response = $ua->post( - $OBT->{'URL_DELETE'}, + $OBT->{'URL_UPDATE'}, { username => $OBT->{UPLOAD_USER}, password => $OBT->{UPLOAD_PASS}, filename => $filename, hash => $hash, + disable => $disable, }, Content_Type => 'form-data' ); + my $status = $disable ? 'Disabled' : 'Enabled'; if ( $response->is_success ) { my ($result) = $response->content =~ /class="error"\>([^<]+)\