]> git.donarmstrong.com Git - debbugs.git/blobdiff - scripts/expire.in
merge changes from dla source branch
[debbugs.git] / scripts / expire.in
index 24494a0cc9f8cd1f7796bc5007051b4ad06b35f2..d5149e945021220b5860e3535062ef5e9c78cb3f 100755 (executable)
@@ -69,6 +69,7 @@ use Debbugs::Control qw(bug_archive);
 use Debbugs::Status qw(bug_archiveable);
 
 use Debbugs::Config qw(:config);
+use Debbugs::Common qw(:lock);
 
 # No $gRemoveAge means "never expire".
 exit 0 unless $config{remove_age};
@@ -77,7 +78,7 @@ chdir($config{spool_dir}) || die "chdir $config{spool_dir} failed: $!\n";
 
 #get list of bugs (ie, status files)
 opendir(DIR,"db-h") or die "Unable to open dir db-h: $!";
-my @dirs = sort { $a <=> $b } grep(s,^,db-h/,, grep(m/^\d+$/,readdir(DIR)));
+my @dirs = sort { $a cmp $b } grep(s,^,db-h/,, grep(m/^\d+$/,readdir(DIR)));
 close(DIR);
 my @list;
 foreach my $dir (@dirs) {
@@ -89,24 +90,26 @@ foreach my $dir (@dirs) {
 my $bug;
 my $errors=0;
 our $exit_now = 0;
-$SIG{INT} = sub {$exit_now=1;};
 #process each bug (ie, status file)
 my @bugs_to_archive = ();
-for my $bug (@list))) {
+for my $bug (@list) {
      # Weeeee.
      print "Examining $bug\n" if $verbose;
      next unless bug_archiveable(bug=>$bug);
      push @bugs_to_archive,$bug;
 }
 
+$SIG{INT} = sub {$exit_now=1;};
 # At this point we want to block control
 if (not lockpid($config{spool_dir}.'/lock/expire.pid')) {
      exit 1;
 }
 # We'll also double check that the bug can be archived
 for my $bug (@bugs_to_archive) {
+     last if $exit_now;
      print "Reexamining $bug\n" if $verbose;
      next unless bug_archiveable(bug=>$bug);
+     last if $exit_now;
      print "Bug $bug can be archived: " if $verbose;
      eval {
          bug_archive(bug=>$bug,
@@ -120,7 +123,7 @@ for my $bug (@bugs_to_archive) {
      }
      last if $exit_now;
 }
-unlink($config{spool_dir}.'/lock/expire.pid')
+unlink($config{spool_dir}.'/lock/expire.pid');
 
 
 exit $errors;