line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Storage for distribution archives |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Pinto::Store; |
4
|
|
|
|
|
|
|
|
5
|
51
|
|
|
51
|
|
303
|
use Moose; |
|
51
|
|
|
|
|
98
|
|
|
51
|
|
|
|
|
309
|
|
6
|
51
|
|
|
51
|
|
299694
|
use MooseX::StrictConstructor; |
|
51
|
|
|
|
|
116
|
|
|
51
|
|
|
|
|
371
|
|
7
|
51
|
|
|
51
|
|
153140
|
use MooseX::MarkAsMethods ( autoclean => 1 ); |
|
51
|
|
|
|
|
120
|
|
|
51
|
|
|
|
|
364
|
|
8
|
|
|
|
|
|
|
|
9
|
51
|
|
|
51
|
|
163125
|
use Try::Tiny; |
|
51
|
|
|
|
|
121
|
|
|
51
|
|
|
|
|
3181
|
|
10
|
51
|
|
|
51
|
|
18329
|
use CPAN::Checksums; |
|
51
|
|
|
|
|
2913091
|
|
|
51
|
|
|
|
|
2779
|
|
11
|
|
|
|
|
|
|
|
12
|
51
|
|
|
51
|
|
4025
|
use Pinto::Util qw(debug throw); |
|
51
|
|
|
|
|
139
|
|
|
51
|
|
|
|
|
18354
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.13'; # VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
with qw( Pinto::Role::UserAgent ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has repo => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
isa => 'Pinto::Repository', |
27
|
|
|
|
|
|
|
weak_ref => 1, |
28
|
|
|
|
|
|
|
required => 1, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
32
|
|
|
|
|
|
|
# TODO: Use named arguments here... |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub add_archive { |
35
|
161
|
|
|
161
|
0
|
40366
|
my ( $self, $origin, $destination ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
161
|
50
|
|
|
|
1258
|
throw "$origin does not exist" if not -e $origin; |
38
|
161
|
50
|
|
|
|
14520
|
throw "$origin is not a file" if not -f $origin; |
39
|
|
|
|
|
|
|
|
40
|
161
|
|
|
|
|
8100
|
$self->mirror( $origin => $destination ); |
41
|
161
|
|
|
|
|
3995
|
$self->update_checksums( directory => $destination->parent ); |
42
|
|
|
|
|
|
|
|
43
|
161
|
|
|
|
|
1063
|
return $self; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
48
|
|
|
|
|
|
|
# TODO: Use named arguments here... |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub remove_archive { |
51
|
18
|
|
|
18
|
0
|
315
|
my ( $self, $archive_file ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
18
|
|
|
|
|
107
|
$self->remove_path( path => $archive_file ); |
54
|
|
|
|
|
|
|
|
55
|
18
|
|
|
|
|
106
|
$self->update_checksums( directory => $archive_file->parent ); |
56
|
|
|
|
|
|
|
|
57
|
18
|
|
|
|
|
110
|
return $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub remove_path { |
63
|
31
|
|
|
31
|
0
|
181
|
my ( $self, %args ) = @_; |
64
|
|
|
|
|
|
|
|
65
|
31
|
|
|
|
|
93
|
my $path = $args{path}; |
66
|
31
|
50
|
|
|
|
134
|
throw "Must specify a path" if not $path; |
67
|
|
|
|
|
|
|
|
68
|
31
|
50
|
|
|
|
270
|
return if not -e $path; |
69
|
|
|
|
|
|
|
|
70
|
31
|
50
|
|
|
|
1480
|
$path->remove or throw "Failed to remove path $path: $!"; |
71
|
|
|
|
|
|
|
|
72
|
31
|
|
|
|
|
3487
|
while ( my $dir = $path->parent ) { |
73
|
80
|
100
|
|
|
|
5149
|
last if $dir->children; |
74
|
49
|
|
|
|
|
7241
|
debug("Removing empty directory $dir"); |
75
|
49
|
50
|
|
|
|
191
|
$dir->remove or throw "Failed to remove directory $dir: $!"; |
76
|
49
|
|
|
|
|
2790
|
$path = $dir; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
31
|
|
|
|
|
11679
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub update_checksums { |
85
|
179
|
|
|
179
|
0
|
2551
|
my ( $self, %args ) = @_; |
86
|
179
|
|
|
|
|
632
|
my $dir = $args{directory}; |
87
|
|
|
|
|
|
|
|
88
|
179
|
50
|
|
|
|
894
|
return 0 if $ENV{PINTO_NO_CHECKSUMS}; |
89
|
179
|
50
|
|
|
|
879
|
return 0 if not -e $dir; # Would be fishy! |
90
|
|
|
|
|
|
|
|
91
|
179
|
|
|
|
|
6469
|
my @children = $dir->children; |
92
|
179
|
50
|
|
|
|
86793
|
return if not @children; |
93
|
|
|
|
|
|
|
|
94
|
179
|
|
|
|
|
832
|
my $cs_file = $dir->file('CHECKSUMS'); |
95
|
|
|
|
|
|
|
|
96
|
179
|
100
|
100
|
|
|
14997
|
if ( -e $cs_file && @children == 1 ) { |
97
|
13
|
|
|
|
|
800
|
$self->remove_path( path => $cs_file ); |
98
|
13
|
|
|
|
|
117
|
return 0; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
166
|
|
|
|
|
8899
|
debug("Generating $cs_file"); |
102
|
|
|
|
|
|
|
|
103
|
166
|
|
|
56
|
|
2740
|
try { CPAN::Checksums::updatedir($dir) } catch { throw "CHECKSUM generation failed for $dir: $_" }; |
|
166
|
|
|
|
|
10839
|
|
|
0
|
|
|
|
|
0
|
|
104
|
|
|
|
|
|
|
|
105
|
166
|
|
|
|
|
2917362
|
return $self; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=pod |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=encoding UTF-8 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=for :stopwords Jeffrey Ryan Thalhammer |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 NAME |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Pinto::Store - Storage for distribution archives |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 VERSION |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
version 0.13 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 DESCRIPTION |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L<Pinto::Store> is the base class for Pinto Stores. It provides the |
131
|
|
|
|
|
|
|
basic API for adding/removing distribution archives to the store. |
132
|
|
|
|
|
|
|
Subclasses implement the underlying logic by augmenting the methods |
133
|
|
|
|
|
|
|
declared here. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 AUTHOR |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Jeffrey Ryan Thalhammer <jeff@stratopan.com> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
144
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |