| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyrights 2001-2023 by [Mark Overmeer]. |
|
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
|
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
|
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.03. |
|
5
|
|
|
|
|
|
|
# This code is part of distribution Mail-Box. Meta-POD processed with |
|
6
|
|
|
|
|
|
|
# OODoc into POD and HTML manual-pages. See README.md |
|
7
|
|
|
|
|
|
|
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Mail::Box::MH::Index; |
|
10
|
11
|
|
|
11
|
|
1334
|
use vars '$VERSION'; |
|
|
11
|
|
|
|
|
22
|
|
|
|
11
|
|
|
|
|
575
|
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.010'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
11
|
|
|
11
|
|
73
|
use base 'Mail::Reporter'; |
|
|
11
|
|
|
|
|
22
|
|
|
|
11
|
|
|
|
|
1084
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
11
|
|
|
11
|
|
83
|
use strict; |
|
|
11
|
|
|
|
|
23
|
|
|
|
11
|
|
|
|
|
337
|
|
|
16
|
11
|
|
|
11
|
|
78
|
use warnings; |
|
|
11
|
|
|
|
|
34
|
|
|
|
11
|
|
|
|
|
367
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
11
|
|
|
11
|
|
5070
|
use Mail::Message::Head::Subset; |
|
|
11
|
|
|
|
|
42
|
|
|
|
11
|
|
|
|
|
414
|
|
|
19
|
11
|
|
|
11
|
|
93
|
use Carp; |
|
|
11
|
|
|
|
|
40
|
|
|
|
11
|
|
|
|
|
8718
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#------------------------------------------- |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub init($) |
|
26
|
4
|
|
|
4
|
0
|
126
|
{ my ($self, $args) = @_; |
|
27
|
4
|
|
|
|
|
25
|
$self->SUPER::init($args); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$self->{MBMI_filename} = $args->{filename} |
|
30
|
4
|
50
|
|
|
|
66
|
or croak "No index filename specified."; |
|
31
|
|
|
|
|
|
|
|
|
32
|
4
|
|
50
|
|
|
27
|
$self->{MBMI_head_wrap} = $args->{head_wrap} || 72; |
|
33
|
|
|
|
|
|
|
$self->{MBMI_head_type} |
|
34
|
4
|
|
50
|
|
|
22
|
= $args->{head_type} || 'Mail::Message::Head::Subset'; |
|
35
|
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
20
|
$self; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#------------------------------------------- |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
6
|
|
|
6
|
1
|
30
|
sub filename() {shift->{MBMI_filename}} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#------------------------------------------- |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub write(@) |
|
48
|
5
|
|
|
5
|
1
|
12
|
{ my $self = shift; |
|
49
|
5
|
50
|
|
|
|
28
|
my $index = $self->filename or return $self; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Remove empty index-file. |
|
52
|
5
|
50
|
|
|
|
18
|
unless(@_) |
|
53
|
0
|
|
|
|
|
0
|
{ unlink $index; |
|
54
|
0
|
|
|
|
|
0
|
return $self; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
5
|
|
|
|
|
14
|
local *INDEX; |
|
58
|
5
|
50
|
|
|
|
359
|
open INDEX, '>:raw', $index |
|
59
|
|
|
|
|
|
|
or return $self; |
|
60
|
|
|
|
|
|
|
|
|
61
|
5
|
|
|
|
|
26
|
my $fieldtype = 'Mail::Message::Field'; |
|
62
|
5
|
|
|
|
|
12
|
my $written = 0; |
|
63
|
|
|
|
|
|
|
|
|
64
|
5
|
|
|
|
|
35
|
foreach my $msg (@_) |
|
65
|
178
|
|
|
|
|
495
|
{ my $head = $msg->head; |
|
66
|
178
|
50
|
66
|
|
|
2175
|
next if $head->isDelayed && $head->isa('Mail::Message::Head::Subset'); |
|
67
|
|
|
|
|
|
|
|
|
68
|
178
|
|
|
|
|
1077
|
my $filename = $msg->filename; |
|
69
|
178
|
|
|
|
|
3194
|
print INDEX "X-MailBox-Filename: $filename\n" |
|
70
|
|
|
|
|
|
|
, 'X-MailBox-Size: ', (-s $filename), "\n"; |
|
71
|
|
|
|
|
|
|
|
|
72
|
178
|
|
|
|
|
2065
|
$head->print(\*INDEX); |
|
73
|
178
|
|
|
|
|
44434
|
$written++; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
5
|
|
|
|
|
399
|
close INDEX; |
|
77
|
|
|
|
|
|
|
|
|
78
|
5
|
50
|
|
|
|
31
|
$written or unlink $index; |
|
79
|
|
|
|
|
|
|
|
|
80
|
5
|
|
|
|
|
47
|
$self; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#------------------------------------------- |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub append(@) |
|
87
|
1
|
|
|
1
|
1
|
2
|
{ my $self = shift; |
|
88
|
1
|
50
|
|
|
|
5
|
my $index = $self->filename or return $self; |
|
89
|
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
3
|
local *INDEX; |
|
91
|
1
|
50
|
|
|
|
60
|
open INDEX, '>>:raw', $index |
|
92
|
|
|
|
|
|
|
or return $self; |
|
93
|
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
5
|
my $fieldtype = 'Mail::Message::Field'; |
|
95
|
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
3
|
foreach my $msg (@_) |
|
97
|
1
|
|
|
|
|
5
|
{ my $head = $msg->head; |
|
98
|
1
|
50
|
33
|
|
|
12
|
next if $head->isDelayed && $head->isa('Mail::Message::Head::Subset'); |
|
99
|
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
5
|
my $filename = $msg->filename; |
|
101
|
1
|
|
|
|
|
21
|
print INDEX "X-MailBox-Filename: $filename\n" |
|
102
|
|
|
|
|
|
|
, 'X-MailBox-Size: ', (-s $filename), "\n"; |
|
103
|
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
8
|
$head->print(\*INDEX); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
150
|
close INDEX; |
|
108
|
1
|
|
|
|
|
10
|
$self; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
#------------------------------------------- |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub read(;$) |
|
115
|
4
|
|
|
4
|
1
|
10
|
{ my $self = shift; |
|
116
|
4
|
|
|
|
|
12
|
my $filename = $self->{MBMI_filename}; |
|
117
|
|
|
|
|
|
|
|
|
118
|
4
|
50
|
|
|
|
37
|
my $parser = Mail::Box::Parser->new |
|
119
|
|
|
|
|
|
|
( filename => $filename |
|
120
|
|
|
|
|
|
|
, mode => 'r' |
|
121
|
|
|
|
|
|
|
) or return; |
|
122
|
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
0
|
my @options = ($self->logSettings, wrap_length => $self->{MBMI_head_wrap}); |
|
124
|
0
|
|
|
|
|
0
|
my $type = $self->{MBMI_head_type}; |
|
125
|
0
|
|
|
|
|
0
|
my $index_age= -M $filename; |
|
126
|
0
|
|
|
|
|
0
|
my %index; |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
0
|
while(my $head = $type->new(@options)->read($parser)) |
|
129
|
|
|
|
|
|
|
{ |
|
130
|
|
|
|
|
|
|
# cleanup the index from files which were renamed |
|
131
|
0
|
|
|
|
|
0
|
my $msgfile = $head->get('x-mailbox-filename'); |
|
132
|
0
|
|
|
|
|
0
|
my $size = int $head->get('x-mailbox-size'); |
|
133
|
0
|
0
|
0
|
|
|
0
|
next unless -f $msgfile && -s _ == $size; |
|
134
|
0
|
0
|
0
|
|
|
0
|
next if defined $index_age && -M _ < $index_age; |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# keep this one |
|
137
|
0
|
|
|
|
|
0
|
$index{$msgfile} = $head; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
0
|
$parser->stop; |
|
141
|
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
0
|
$self->{MBMI_index} = \%index; |
|
143
|
0
|
|
|
|
|
0
|
$self; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
#------------------------------------------- |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub get($) |
|
150
|
94
|
|
|
94
|
1
|
178
|
{ my ($self, $msgfile) = @_; |
|
151
|
94
|
|
|
|
|
196
|
$self->{MBMI_index}{$msgfile}; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#------------------------------------------- |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
1; |