From: Don Armstrong Date: Thu, 19 Jun 2008 00:10:35 +0000 (-0700) Subject: * Add support for the correspondent index X-Git-Tag: release/2.6.0~488^2~35 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1d60f62c7a38372911e31e108bac2fd14f032dc6;p=debbugs.git * Add support for the correspondent index --- diff --git a/scripts/gen-indices b/scripts/gen-indices index 11775e4..ca11546 100755 --- a/scripts/gen-indices +++ b/scripts/gen-indices @@ -1,8 +1,13 @@ #!/usr/bin/perl +# gen-indices generates bug index files, and is released +# under the terms of the GPL version 2, or any later version, at your +# option. See the file README and COPYING for more information. -# Generates by-*.idx files for the CGI scripts # Copyright (c) 2005/08/03 Anthony Towns -# GPL v2 +# Copyright 2007, 2008 by Don Armstrong . + +use warnings; +use strict; use DB_File; use MLDBM qw(DB_FILE Storable); @@ -12,9 +17,6 @@ use File::Copy; use Getopt::Long; use Pod::Usage; -use warnings; -use strict; - use File::stat; use List::Util qw(min); @@ -78,6 +80,7 @@ pod2usage(-verbose=>2) if $options{man}; use Debbugs::Config qw(:config); use Debbugs::Common qw(getparsedaddrs getbugcomponent lockpid); use Debbugs::Status qw(readbug); +use Debbugs::Log; chdir($config{spool_dir}) or die "chdir $config{spool_dir} failed: $!"; @@ -103,7 +106,7 @@ if (not lockpid($config{spool_dir}.'/lock/gen-indices')) { } # NB: The reverse index is special; it's used to clean up during updates to bugs -my @indexes = ('package', 'tag', 'severity','owner','submitter-email','status','reverse'); +my @indexes = ('package', 'tag', 'severity','owner','submitter-email','status','correspondent','reverse'); my $indexes; my %slow_index = (); my %fast_index = (); @@ -200,7 +203,23 @@ while (my $dir = shift @dirs) { addbugtoindex("severity", $bug, $fdata->{"severity"}); addbugtoindex("owner", $bug, map {lc($_->address)} getparsedaddrs($fdata->{"owner"})); - } + # handle log entries + # do this in eval to avoid exploding on jacked logs + eval { + my $log = Debbugs::Log->new(bug_num => $bug); + while (my $record = $log->read_record()) { + next unless $record->{type} eq 'incoming-recv'; + # we use a regex here, because a full mime parse will be slow. + my ($from) = $record->{text} =~ /^From:\s+(.+?)^\S/ism; + addbugtoindex('correspondent',$bug, + map {lc($_->address)} getparsedaddrs($from) + ); + } + }; + if ($@) { + print STDERR "Problem dealing with log of $bug: $@"; + } + } } if (not $options{quick}) {