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

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

version 1.8, 2005/05/05 02:07:16 version 1.13, 2007/11/02 03:35:07
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl -T
 #$Id$  #$RedRiver: NewTorrents.pl,v 1.12 2007/10/01 20:17:23 andrew Exp $
 use strict;  use strict;
 use warnings;  use warnings;
 use diagnostics;  use diagnostics;
Line 15 
Line 15 
   
 %ENV = ();  %ENV = ();
   
 use YAML;  
   
 # *** This requires --log-format="%t [%p] %o %f %l" on the rsync command  
   
 my $last_dir = '';  my $last_dir = '';
 while (<>) {  while (<>) {
           #print;
         chomp;          chomp;
         if (my ($year,  $mon,  $mday,   $time,               $pid,   $oper, $file, $size) =          if (my ($message, $file) = m#(.*)\s+\`([^']+)'#) {
             m#^(\d{4})/(\d{2})/(\d{2}) (\d{2}:\d{2}:\d{2}) \[(\d+)\] (\S+) (.+) (\d+)$# ) {                  next if $message eq 'Mirroring directory';
                 #print "($year, $mon, $mday, $time, $pid, $oper, $file, $size)\n";                  next if $message eq 'Making directory';
                 my ($dir, $file) = $file =~ m#^(.*)/([^/]+)#;  
                 #print "$dir - $file\n";                  my $dir = '';
                   if ($file =~ m#^(.*)/([^/]+)#) {
                           ($dir, $file) = ($1, $2);
                   }
                   #print "$message - ($last_dir) $dir - $file\n";
                   print "$message - $dir - $file\n";
                 if ($last_dir && $last_dir ne $dir) {                  if ($last_dir && $last_dir ne $dir) {
                         StartTorrent($last_dir);                          StartTorrent($last_dir);
                 }                  }
                 $last_dir = $dir;                  $last_dir = $dir;
         } else {  
                 #print $_;  
         }          }
 }  }
   
Line 44 
Line 44 
 sleep(1) while (keys %Kids > 0);  sleep(1) while (keys %Kids > 0);
 StartTorrent('skip');  StartTorrent('skip');
   
   # and wait for it to finish
   sleep(1) while (keys %Kids > 0);
   
 sub REAPER {  sub REAPER {
         my $child;          my $child;
         while (($child = waitpid(-1,WNOHANG)) > 0) {          while (($child = waitpid(-1,WNOHANG)) > 0) {
Line 57 
Line 60 
 {  {
         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') {
Line 86 
Line 91 
                 }                  }
   
         }          }
   
         chdir $OBT->{DIR_HOME} or die "Can't chdir to $OBT->{DIR_HOME}: $!";  
   
         if (@now_update) {          if (@now_update) {
                 print "Making torrents for ", join(" ", @now_update), "\n";                  print "Making torrents for ", join(" ", @now_update), "\n";

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

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