line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Storage for distribution archives |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Pinto::Store; |
4
|
|
|
|
|
|
|
|
5
|
51
|
|
|
51
|
|
307
|
use Moose; |
|
51
|
|
|
|
|
114
|
|
|
51
|
|
|
|
|
349
|
|
6
|
51
|
|
|
51
|
|
316722
|
use MooseX::StrictConstructor; |
|
51
|
|
|
|
|
111
|
|
|
51
|
|
|
|
|
419
|
|
7
|
51
|
|
|
51
|
|
156426
|
use MooseX::MarkAsMethods ( autoclean => 1 ); |
|
51
|
|
|
|
|
119
|
|
|
51
|
|
|
|
|
431
|
|
8
|
|
|
|
|
|
|
|
9
|
51
|
|
|
51
|
|
172178
|
use Try::Tiny; |
|
51
|
|
|
|
|
118
|
|
|
51
|
|
|
|
|
3953
|
|
10
|
51
|
|
|
51
|
|
22273
|
use CPAN::Checksums; |
|
51
|
|
|
|
|
2967100
|
|
|
51
|
|
|
|
|
2995
|
|
11
|
|
|
|
|
|
|
|
12
|
51
|
|
|
51
|
|
5418
|
use Pinto::Util qw(debug throw); |
|
51
|
|
|
|
|
133
|
|
|
51
|
|
|
|
|
17726
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.14'; # 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
|
38469
|
my ( $self, $origin, $destination ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
161
|
50
|
|
|
|
1167
|
throw "$origin does not exist" if not -e $origin; |
38
|
161
|
50
|
|
|
|
13416
|
throw "$origin is not a file" if not -f $origin; |
39
|
|
|
|
|
|
|
|
40
|
161
|
|
|
|
|
7521
|
$self->mirror( $origin => $destination ); |
41
|
161
|
|
|
|
|
3751
|
$self->update_checksums( directory => $destination->parent ); |
42
|
|
|
|
|
|
|
|
43
|
161
|
|
|
|
|
997
|
return $self; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
48
|
|
|
|
|
|
|
# TODO: Use named arguments here... |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub remove_archive { |
51
|
18
|
|
|
18
|
0
|
510
|
my ( $self, $archive_file ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
18
|
|
|
|
|
97
|
$self->remove_path( path => $archive_file ); |
54
|
|
|
|
|
|
|
|
55
|
18
|
|
|
|
|
88
|
$self->update_checksums( directory => $archive_file->parent ); |
56
|
|
|
|
|
|
|
|
57
|
18
|
|
|
|
|
85
|
return $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub remove_path { |
63
|
31
|
|
|
31
|
0
|
129
|
my ( $self, %args ) = @_; |
64
|
|
|
|
|
|
|
|
65
|
31
|
|
|
|
|
74
|
my $path = $args{path}; |
66
|
31
|
50
|
|
|
|
110
|
throw "Must specify a path" if not $path; |
67
|
|
|
|
|
|
|
|
68
|
31
|
50
|
|
|
|
236
|
return if not -e $path; |
69
|
|
|
|
|
|
|
|
70
|
31
|
50
|
|
|
|
1279
|
$path->remove or throw "Failed to remove path $path: $!"; |
71
|
|
|
|
|
|
|
|
72
|
31
|
|
|
|
|
3275
|
while ( my $dir = $path->parent ) { |
73
|
80
|
100
|
|
|
|
4617
|
last if $dir->children; |
74
|
49
|
|
|
|
|
6355
|
debug("Removing empty directory $dir"); |
75
|
49
|
50
|
|
|
|
166
|
$dir->remove or throw "Failed to remove directory $dir: $!"; |
76
|
49
|
|
|
|
|
2412
|
$path = $dir; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
31
|
|
|
|
|
10704
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub update_checksums { |
85
|
179
|
|
|
179
|
0
|
2397
|
my ( $self, %args ) = @_; |
86
|
179
|
|
|
|
|
537
|
my $dir = $args{directory}; |
87
|
|
|
|
|
|
|
|
88
|
179
|
50
|
|
|
|
872
|
return 0 if $ENV{PINTO_NO_CHECKSUMS}; |
89
|
179
|
50
|
|
|
|
804
|
return 0 if not -e $dir; # Would be fishy! |
90
|
|
|
|
|
|
|
|
91
|
179
|
|
|
|
|
5986
|
my @children = $dir->children; |
92
|
179
|
50
|
|
|
|
79594
|
return if not @children; |
93
|
|
|
|
|
|
|
|
94
|
179
|
|
|
|
|
730
|
my $cs_file = $dir->file('CHECKSUMS'); |
95
|
|
|
|
|
|
|
|
96
|
179
|
100
|
100
|
|
|
13735
|
if ( -e $cs_file && @children == 1 ) { |
97
|
13
|
|
|
|
|
655
|
$self->remove_path( path => $cs_file ); |
98
|
13
|
|
|
|
|
105
|
return 0; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
166
|
|
|
|
|
8370
|
debug("Generating $cs_file"); |
102
|
|
|
|
|
|
|
|
103
|
166
|
|
|
62
|
|
2575
|
try { CPAN::Checksums::updatedir($dir) } catch { throw "CHECKSUM generation failed for $dir: $_" }; |
|
166
|
|
|
|
|
9769
|
|
|
0
|
|
|
|
|
0
|
|
104
|
|
|
|
|
|
|
|
105
|
166
|
|
|
|
|
2682778
|
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.14 |
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 |