[BACK]Return to ServerTorrents.pl CVS log [TXT][DIR] Up to [local] / openbsd / OpenBSDTorrents

Diff for /openbsd/OpenBSDTorrents/ServerTorrents.pl between version 1.29 and 1.30

version 1.29, 2010/03/08 20:19:37 version 1.30, 2011/12/08 02:08:09
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl -T
 #$RedRiver: ServerTorrents.pl,v 1.28 2010/01/07 18:50:02 andrew Exp $  #$RedRiver: ServerTorrents.pl,v 1.29 2010/03/08 20:19:37 andrew Exp $
 use strict;  use strict;
 use warnings;  use warnings;
 use diagnostics;  use diagnostics;
Line 99 
Line 99 
     if ( !exists $server_torrents{$hash} ) {      if ( !exists $server_torrents{$hash} ) {
         Upload_Torrent( $torrents{$hash} );          Upload_Torrent( $torrents{$hash} );
     }      }
       elsif ( $server_torrents{$hash}{disabled} ) {
           Update_Torrent( $server_torrents{$hash}{name}, $hash );
       }
 }  }
 closedir DIR;  closedir DIR;
   
Line 111 
Line 114 
     if (   ( !exists $torrents{$hash} )      if (   ( !exists $torrents{$hash} )
         && ( !$server_torrents{$hash}{disabled} ) )          && ( !$server_torrents{$hash}{disabled} ) )
     {      {
         Delete_Torrent( $server_torrents{$hash}{name}, $hash );          Update_Torrent( $server_torrents{$hash}{name}, $hash, 1 );
     }      }
 }  }
   
Line 185 
Line 188 
     }      }
 }  }
   
 sub Delete_Torrent {  sub Update_Torrent {
     my $filename = shift;      my $filename = shift;
     my $hash     = shift;      my $hash     = shift;
       my $disable  = shift || 0;
     die "No hash passed!" unless $hash;      die "No hash passed!" unless $hash;
   
     #print "Removing $filename [$hash]\n";      #print "Removing $filename [$hash]\n";
   
     my $response = $ua->post(      my $response = $ua->post(
         $OBT->{'URL_DELETE'},          $OBT->{'URL_UPDATE'},
         {   username => $OBT->{UPLOAD_USER},          {   username => $OBT->{UPLOAD_USER},
             password => $OBT->{UPLOAD_PASS},              password => $OBT->{UPLOAD_PASS},
             filename => $filename,              filename => $filename,
             hash     => $hash,              hash     => $hash,
               disable  => $disable,
         },          },
         Content_Type => 'form-data'          Content_Type => 'form-data'
     );      );
       my $status = $disable ? 'Disabled' : 'Enabled';
   
     if ( $response->is_success ) {      if ( $response->is_success ) {
         my ($result) = $response->content =~ /class="error"\>([^<]+)\</;          my ($result) = $response->content =~ /class="error"\>([^<]+)\</;
   
         if ( $result eq 'Torrent was removed successfully.' ) {          if ( $result eq 'Torrent disabled set to ' . $disable ) {
             print STDERR "Removed $filename [$hash]\n";              print STDERR "$status $filename [$hash]\n";
         }          }
         elsif ($result) {          elsif ($result) {
             print STDERR "Error: $result (removing $filename [$hash])\n";              print STDERR "Error: $result (removing $filename [$hash])\n";

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>