line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Action::Storage; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
63
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.46'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
771
|
use YAML; |
|
1
|
|
|
|
|
10453
|
|
|
1
|
|
|
|
|
72
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
11
|
use Carp 'croak'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
12
|
1
|
|
|
1
|
|
5
|
use Fcntl ':flock'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
161
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use File::Spec; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
552
|
use Mail::Action::Address; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
538
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new |
19
|
|
|
|
|
|
|
{ |
20
|
11
|
|
|
11
|
1
|
20
|
my ($class, $directory) = @_; |
21
|
11
|
100
|
|
|
|
50
|
croak 'No storage directory given' unless $directory; |
22
|
|
|
|
|
|
|
|
23
|
10
|
|
|
|
|
60
|
bless { storage_dir => $directory }, $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub stored_class |
27
|
|
|
|
|
|
|
{ |
28
|
1
|
|
|
1
|
1
|
6
|
''; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub storage_dir |
32
|
|
|
|
|
|
|
{ |
33
|
7
|
|
|
7
|
1
|
14
|
my $self = shift; |
34
|
7
|
|
|
|
|
53
|
return $self->{storage_dir}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub storage_extension |
38
|
|
|
|
|
|
|
{ |
39
|
7
|
|
|
7
|
1
|
258
|
'mas' |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub storage_file |
43
|
|
|
|
|
|
|
{ |
44
|
6
|
|
|
6
|
1
|
11
|
my ($self, $name) = @_; |
45
|
6
|
|
|
|
|
28
|
return File::Spec->catfile( $self->storage_dir(), |
46
|
|
|
|
|
|
|
$name . '.' . $self->storage_extension() ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub create |
50
|
0
|
|
|
0
|
1
|
0
|
{ |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub exists |
54
|
|
|
|
|
|
|
{ |
55
|
2
|
|
|
2
|
1
|
7
|
my ($self, $address) = @_; |
56
|
2
|
|
|
|
|
8
|
return -e $self->storage_file( $address ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub save |
60
|
|
|
|
|
|
|
{ |
61
|
2
|
|
|
2
|
1
|
5
|
my ($self, $stored, $name) = @_; |
62
|
2
|
|
|
|
|
8
|
my $file = $self->storage_file( $name ); |
63
|
2
|
|
|
|
|
6
|
delete $stored->{name}; |
64
|
|
|
|
|
|
|
|
65
|
2
|
|
|
|
|
6
|
local *OUT; |
66
|
|
|
|
|
|
|
|
67
|
2
|
50
|
|
|
|
64
|
if (-e $file) |
68
|
|
|
|
|
|
|
{ |
69
|
0
|
0
|
|
|
|
0
|
open( OUT, '+< ' . $file ) or croak "Cannot save data for '$file': $!"; |
70
|
0
|
|
|
|
|
0
|
flock OUT, LOCK_EX; |
71
|
0
|
|
|
|
|
0
|
seek OUT, 0, 0; |
72
|
0
|
|
|
|
|
0
|
truncate OUT, 0; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else |
75
|
|
|
|
|
|
|
{ |
76
|
2
|
50
|
|
|
|
214
|
open( OUT, '> ' . $file ) or croak "Cannot save data for '$file': $!"; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
2
|
|
|
|
|
19
|
print OUT Dump { %$stored }; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub fetch |
83
|
|
|
|
|
|
|
{ |
84
|
1
|
|
|
1
|
1
|
4
|
my ($self, $name) = @_; |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
3
|
local *IN; |
87
|
1
|
50
|
|
|
|
10
|
open( IN, $self->storage_file( $name ) ) or return; |
88
|
1
|
|
|
|
|
11
|
flock( IN, LOCK_SH ); |
89
|
1
|
|
|
|
|
2
|
my $data = do { local $/; }; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
28
|
|
90
|
1
|
|
|
|
|
11
|
close IN; |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
6
|
return $self->stored_class->new( |
93
|
1
|
|
|
|
|
7
|
%{ Load( $data ) }, name => $name |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |