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::Download; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '1.114_2'; |
24
|
|
|
|
|
|
|
|
25
|
8
|
|
|
8
|
|
100974
|
use strict; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
190
|
|
26
|
8
|
|
|
8
|
|
36
|
use warnings; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
169
|
|
27
|
8
|
|
|
8
|
|
30
|
use Carp; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
352
|
|
28
|
|
|
|
|
|
|
|
29
|
8
|
|
|
8
|
|
41
|
use App::MtAws::QueueJobResult; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
407
|
|
30
|
8
|
|
|
8
|
|
2760
|
use App::MtAws::QueueJob::DownloadSegments; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
200
|
|
31
|
8
|
|
|
8
|
|
3957
|
use App::MtAws::QueueJob::DownloadSingle; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
190
|
|
32
|
8
|
|
|
8
|
|
40
|
use base 'App::MtAws::QueueJob'; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
2227
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub init |
35
|
|
|
|
|
|
|
{ |
36
|
177
|
|
|
177
|
0
|
167
|
my ($self) = @_; |
37
|
177
|
100
|
|
|
|
500
|
$self->{archive_id}||confess; |
38
|
175
|
100
|
|
|
|
465
|
defined($self->{relfilename})||confess; |
39
|
174
|
100
|
|
|
|
368
|
defined($self->{filename})||confess; |
40
|
173
|
100
|
|
|
|
356
|
$self->{file_downloads}||confess; |
41
|
172
|
100
|
|
|
|
415
|
$self->{jobid}||confess; |
42
|
170
|
100
|
|
|
|
413
|
$self->{size}||confess; |
43
|
168
|
100
|
|
|
|
386
|
defined($self->{mtime})||confess; |
44
|
167
|
100
|
|
|
|
424
|
$self->{treehash}||confess; |
45
|
165
|
|
|
|
|
348
|
$self->enter("download"); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub on_download |
50
|
|
|
|
|
|
|
{ |
51
|
161
|
|
|
161
|
0
|
168
|
my ($self) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $job = ($self->{file_downloads}{'segment-size'} && $self->{size} > $self->{file_downloads}{'segment-size'}*1048576) ? |
54
|
378
|
|
|
|
|
502
|
App::MtAws::QueueJob::DownloadSegments->new(map { $_ => $self->{$_} } qw/size archive_id jobid file_downloads relfilename filename mtime/) : |
55
|
161
|
100
|
66
|
|
|
889
|
App::MtAws::QueueJob::DownloadSingle->new(map { $_ => $self->{$_} } qw/archive_id relfilename filename jobid size mtime treehash/); |
|
749
|
|
|
|
|
1120
|
|
56
|
161
|
|
|
155
|
|
448
|
return state("wait"), job($job, sub { state("done") }); |
|
155
|
|
|
|
|
292
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |