/[mws]/trunk/mbox2index.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/mbox2index.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (show annotations)
Fri May 7 11:25:01 2004 UTC (19 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 1480 byte(s)
max_results option in configuration, better decoding of strange data
from headers

1 #!/usr/bin/perl -w
2
3 use MWS;
4 use Data::Dumper;
5 use Date::Parse;
6 use POSIX qw(strftime);
7
8 my $mws = MWS->new('global.conf');
9
10 my $debug = 1;
11
12 foreach my $mbox ($mws->{config}->Parameters('folders')) {
13 my $mbox_path = $mws->{config}->val('folders', $mbox);
14
15 print STDERR "working on $mbox [$mbox_path]\n" if ($debug);
16
17 my $folder = $mws->open_folder($mbox);
18
19 print STDERR $folder->size," bytes\n" if ($debug);
20
21 foreach my $message ($folder->messages) {
22
23 my $id = $message->messageId;
24
25 my $document = {
26 id => $id,
27 folder => $mbox,
28 };
29
30 foreach my $direction (qw(to from cc bcc)) {
31 foreach my $part (qw(phrase address comment)) {
32 $document->{$direction.'_'.$part} = join("##", $mws->unroll($message,$direction,$part));
33 }
34 }
35
36 $document->{'subject'} = $mws->decode_qp($message->subject) || 'no subject';
37
38 $document->{'body'} = $mws->plain_text_body($message);
39
40 my $utime = str2time($message->date);
41
42 $document->{'date_utime'} = $utime;
43 $document->{'date'} = strftime("%Y-%m-%d %H:%M:%S", localtime($utime));
44
45 # print Dumper($document);
46 $mws->add_index("$mbox $id" => $document);
47
48 # clear internal MWS cache to keep memory usage down
49 # (this should be replaced by garbage collector in MWS,
50 # but without it this is the best solution to keep machine
51 # alive while indexing)
52 $mws->{cache} = {};
53
54 # this is not complete solution. see mailbox-destruct.diff
55 $message->destruct();
56
57 }
58
59 $mws->close_folder($mbox);
60
61 }
62
63 $mws->close_index;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26