| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# mt-aws-glacier - Amazon Glacier sync client |
|
2
|
|
|
|
|
|
|
# Copyright (C) 2012-2014 Victor Efimov |
|
3
|
|
|
|
|
|
|
# http://mt-aws.com (also http://vs-dev.com) vs@vs-dev.com |
|
4
|
|
|
|
|
|
|
# License: GPLv3 |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# This file is part of "mt-aws-glacier" |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# mt-aws-glacier is free software: you can redistribute it and/or modify |
|
9
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
|
10
|
|
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
|
11
|
|
|
|
|
|
|
# (at your option) any later version. |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# mt-aws-glacier is distributed in the hope that it will be useful, |
|
14
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
|
|
|
|
# GNU General Public License for more details. |
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
19
|
|
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package App::MtAws::QueueJob::FetchAndDownloadInventory; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '1.114_2'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
3
|
|
|
3
|
|
692
|
use strict; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
73
|
|
|
26
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
61
|
|
|
27
|
3
|
|
|
3
|
|
8
|
use Carp; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
113
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
3
|
|
|
3
|
|
10
|
use App::MtAws::QueueJobResult; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
143
|
|
|
30
|
3
|
|
|
3
|
|
1309
|
use App::MtAws::QueueJob::DownloadInventory; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
84
|
|
|
31
|
3
|
|
|
3
|
|
16
|
use base 'App::MtAws::QueueJob'; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
182
|
|
|
32
|
3
|
|
|
3
|
|
861
|
use App::MtAws::Glacier::ListJobs; |
|
|
3
|
|
|
|
|
1105
|
|
|
|
3
|
|
|
|
|
1453
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub init |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
26
|
|
|
26
|
0
|
54
|
my ($self) = @_; |
|
37
|
26
|
|
|
|
|
51
|
$self->{marker} = undef; |
|
38
|
26
|
|
|
|
|
50
|
$self->{all_jobs} = []; |
|
39
|
26
|
|
|
|
|
82
|
$self->enter("list"); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub on_list |
|
43
|
|
|
|
|
|
|
{ |
|
44
|
86
|
|
|
86
|
0
|
90
|
my ($self) = @_; |
|
45
|
|
|
|
|
|
|
return state "wait", task "inventory_fetch_job", { marker => $self->{marker} } => sub { |
|
46
|
86
|
|
|
86
|
|
132
|
my ($args) = @_; |
|
47
|
|
|
|
|
|
|
|
|
48
|
86
|
|
33
|
|
|
529
|
my ($marker, @jobs) = App::MtAws::Glacier::ListJobs->new( $args->{response} || confess )->get_inventory_entries(); |
|
49
|
86
|
|
|
|
|
913
|
push @{$self->{all_jobs}}, @jobs; |
|
|
86
|
|
|
|
|
219
|
|
|
50
|
86
|
100
|
|
|
|
160
|
if ($marker) { |
|
51
|
60
|
|
|
|
|
83
|
$self->{marker} = $marker; |
|
52
|
60
|
|
|
|
|
178
|
return state 'list'; |
|
53
|
|
|
|
|
|
|
} else { |
|
54
|
26
|
|
|
|
|
76
|
return state 'sort'; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
86
|
|
|
|
|
192
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub on_sort |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
26
|
|
|
26
|
0
|
39
|
my ($self) = @_; |
|
62
|
|
|
|
|
|
|
|
|
63
|
26
|
100
|
|
|
|
39
|
if (@{ $self->{all_jobs} }) { |
|
|
26
|
|
|
|
|
80
|
|
|
64
|
22
|
|
|
|
|
29
|
my $first = undef; |
|
65
|
22
|
|
|
|
|
27
|
for (@{ $self->{all_jobs} }) { |
|
|
22
|
|
|
|
|
58
|
|
|
66
|
310
|
100
|
100
|
|
|
953
|
$first = $_ if (!$first || $_->{CreationDate} gt $first->{CreationDate}); # "gt" - stable "sort" here, but why? |
|
67
|
|
|
|
|
|
|
} |
|
68
|
22
|
|
33
|
|
|
75
|
$self->{found_job} = $first->{JobId} || confess; |
|
69
|
22
|
|
|
|
|
72
|
return state 'download'; |
|
70
|
|
|
|
|
|
|
} else { |
|
71
|
4
|
|
|
|
|
11
|
$self->{inventory_raw_ref} = undef; |
|
72
|
4
|
|
|
|
|
9
|
$self->{inventory_type} = undef; |
|
73
|
4
|
|
|
|
|
14
|
return state 'done'; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub on_download |
|
78
|
|
|
|
|
|
|
{ |
|
79
|
22
|
|
|
22
|
0
|
47
|
my ($self) = @_; |
|
80
|
|
|
|
|
|
|
return state("wait"), |
|
81
|
|
|
|
|
|
|
job( App::MtAws::QueueJob::DownloadInventory->new(job_id => $self->{found_job}||confess), sub { |
|
82
|
22
|
|
|
22
|
|
43
|
my ($j) = @_; |
|
83
|
22
|
|
33
|
|
|
80
|
$self->{inventory_raw_ref} = $j->{inventory_raw_ref} || confess; |
|
84
|
22
|
|
33
|
|
|
72
|
$self->{inventory_type} = $j->{inventory_type} || confess; |
|
85
|
22
|
|
|
|
|
52
|
state("done") |
|
86
|
22
|
|
33
|
|
|
62
|
}); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |