4 |
use Data::Dumper; |
use Data::Dumper; |
5 |
use Date::Parse; |
use Date::Parse; |
6 |
use POSIX qw(strftime); |
use POSIX qw(strftime); |
7 |
|
use Getopt::Long; |
8 |
|
|
9 |
my $mws = MWS->new('global.conf'); |
# are we called from this script? |
10 |
|
my $recursive = 0; |
11 |
|
|
12 |
|
my $r = GetOptions("recursive" => \$recursive); |
13 |
|
|
14 |
|
my $config_file = shift @ARGV || 'global.conf'; |
15 |
|
|
16 |
|
if (! -f $config_file) { |
17 |
|
print qq{Usage: $0 [/path/to/local.conf] |
18 |
|
|
19 |
|
If local.conf is not specified, global.conf in current directory will |
20 |
|
be used. |
21 |
|
}; |
22 |
|
exit 1; |
23 |
|
} |
24 |
|
|
25 |
|
my $mws = MWS->new($config_file); |
26 |
|
|
27 |
|
$mws->create_index if (! $recursive); |
28 |
|
|
29 |
|
print STDERR "starting indexing..."; |
30 |
|
|
31 |
my $debug = 1; |
my $debug = 1; |
32 |
|
|
54 |
} |
} |
55 |
} |
} |
56 |
|
|
57 |
$document->{'subject'} = $message->get('Subject') || 'no subject'; |
$document->{'subject'} = $mws->decode_qp($message->subject) || 'no subject'; |
58 |
|
|
59 |
$document->{'body'} = $mws->plain_text_body($message); |
$document->{'body'} = $mws->plain_text_body($message); |
60 |
|
|
72 |
# alive while indexing) |
# alive while indexing) |
73 |
$mws->{cache} = {}; |
$mws->{cache} = {}; |
74 |
|
|
75 |
undef $message; |
# this is not complete solution. see mailbox-destruct.diff |
76 |
|
$message->destruct(); |
77 |
|
|
78 |
} |
} |
79 |
|
|
80 |
$mws->close_folder($mbox); |
$mws->close_folder($mbox); |
81 |
#$folder->close; |
|
82 |
} |
} |
83 |
|
|
84 |
$mws->close_index; |
$mws->close_index; |