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

Diff for /openbsd/OpenBSDTorrents/NewTorrents.pl between version 1.13 and 1.14

version 1.13, 2007/11/02 03:35:07 version 1.14, 2009/10/20 20:03:25
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl -T
 #$RedRiver: NewTorrents.pl,v 1.12 2007/10/01 20:17:23 andrew Exp $  #$RedRiver: NewTorrents.pl,v 1.13 2007/11/02 02:35:07 andrew Exp $
 use strict;  use strict;
 use warnings;  use warnings;
 use diagnostics;  use diagnostics;
Line 19 
Line 19 
 while (<>) {  while (<>) {
         #print;          #print;
         chomp;          chomp;
         if (my ($message, $file) = m#(.*)\s+\`([^']+)'#) {          # *** This requires --log-format="%t [%p] %o %f %l" on the rsync command
                 next if $message eq 'Mirroring directory';          if (my ($year,  $mon,   $mday,     $time,
                 next if $message eq 'Making directory';                  $pid,        $oper,    $file,  $size) = m#^
                   (\d{4})/(\d{2})/(\d{2}) \s (\d{2}:\d{2}:\d{2}) \s
                   \[(\d+)\] \s (\S+) \s  (.+) \s (\d+)
                   $#xms) {
   
                 my $dir = '';                  $file =~ s/^.*$OBT->{BASENAME}\/?//;
                 if ($file =~ m#^(.*)/([^/]+)#) {  
                         ($dir, $file) = ($1, $2);                  my ($dir, $file) = $file =~ m#^(.*)/([^/]+)#;
                 }                  #print "$oper - ($last_dir) [$dir]/[$file]\n";
                 #print "$message - ($last_dir) $dir - $file\n";  
                 print "$message - $dir - $file\n";                  next unless $oper eq 'recv';
                   next unless $size;
                   next unless $dir;
   
                 if ($last_dir && $last_dir ne $dir) {                  if ($last_dir && $last_dir ne $dir) {
                         StartTorrent($last_dir);                          StartTorrent($last_dir);
                 }                  }
Line 54 
Line 60 
                 delete $Kids{$child};                  delete $Kids{$child};
         }          }
         $SIG{CHLD} = \&REAPER;  # still loathe sysV          $SIG{CHLD} = \&REAPER;  # still loathe sysV
   
           StartTorrent('waiting');
 }  }
   
 sub StartTorrent  sub StartTorrent
 {  {
         my $dir = shift;          my $dir = shift;
         return undef unless $dir;          return undef unless $dir;
         $dir =~ s/^.*$OBT->{BASENAME}\///;  
   
         print "Starting '$dir'\n";  
         my $should_fork = 1;          my $should_fork = 1;
   
         if ($dir eq 'skip') {          if ($dir eq 'skip') {
                 #$dir = '';                  #$dir = '';
                 %Need_Update = ();                  %Need_Update = ();
                 $should_fork = 0;                  $should_fork = 0;
         } else {          }
           elsif ($dir eq 'waiting') {
                   return if ! %Need_Update;
   
                   my $count = scalar keys %Need_Update;
                   print "Need to make $count waiting torrents\n";
           }
           else {
                   print "Need to make torrent for '$dir'\n";
                 $dir = $OBT->{BASENAME} . "/$dir";                  $dir = $OBT->{BASENAME} . "/$dir";
                 $Need_Update{$dir} = 1;                  $Need_Update{$dir} = 1;
         }          }
   
         if (keys %Kids > 0) {          if (keys %Kids > 0) {
                 print "Not making torrents for $dir now, already running\n";                  print "Not making torrents for $dir now, already running\n";
                 return undef;                  return;
         }          }
   
         my @now_update = keys %Need_Update;          my @now_update = keys %Need_Update;
Line 87 
Line 101 
   
                 if ($pid) {                  if ($pid) {
                         $Kids{$pid} = 1;                          $Kids{$pid} = 1;
                         return undef;                          return;
                 }                  }
   
         }          }
Line 99 
Line 113 
                 push @now_update, $dir;                  push @now_update, $dir;
         }          }
         exec($OBT->{DIR_HOME} . '/regen.sh', @now_update);          exec($OBT->{DIR_HOME} . '/regen.sh', @now_update);
           exit;
 }  }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

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