| 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::MultipartCreate; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '1.114_2'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
11
|
|
|
11
|
|
99628
|
use strict; |
|
|
11
|
|
|
|
|
18
|
|
|
|
11
|
|
|
|
|
285
|
|
|
26
|
11
|
|
|
11
|
|
45
|
use warnings; |
|
|
11
|
|
|
|
|
14
|
|
|
|
11
|
|
|
|
|
247
|
|
|
27
|
11
|
|
|
11
|
|
41
|
use Carp; |
|
|
11
|
|
|
|
|
18
|
|
|
|
11
|
|
|
|
|
531
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
11
|
|
|
11
|
|
685
|
use App::MtAws::QueueJobResult; |
|
|
11
|
|
|
|
|
19
|
|
|
|
11
|
|
|
|
|
596
|
|
|
30
|
11
|
|
|
11
|
|
715
|
use App::MtAws::Exceptions; |
|
|
11
|
|
|
|
|
16
|
|
|
|
11
|
|
|
|
|
642
|
|
|
31
|
11
|
|
|
11
|
|
52
|
use App::MtAws::Utils; |
|
|
11
|
|
|
|
|
13
|
|
|
|
11
|
|
|
|
|
1407
|
|
|
32
|
11
|
|
|
11
|
|
50
|
use base 'App::MtAws::QueueJob'; |
|
|
11
|
|
|
|
|
12
|
|
|
|
11
|
|
|
|
|
5339
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub init |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
46
|
|
|
46
|
0
|
70
|
my ($self) = @_; |
|
37
|
46
|
100
|
100
|
|
|
556
|
defined($self->{filename}) xor $self->{stdin} or confess "filename xor stdin should be specified"; |
|
38
|
43
|
100
|
|
|
|
176
|
defined($self->{relfilename}) || confess "no relfilename"; |
|
39
|
42
|
100
|
|
|
|
376
|
$self->{partsize}||confess "no partsize"; |
|
40
|
40
|
|
|
|
|
121
|
$self->enter('create'); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub init_file |
|
44
|
|
|
|
|
|
|
{ |
|
45
|
19
|
|
|
19
|
0
|
166
|
my ($self) = @_; |
|
46
|
19
|
100
|
|
|
|
70
|
if ($self->{stdin}) { |
|
47
|
1
|
|
|
|
|
9
|
$self->{mtime} = time(); # should be as close as possible to upload process time |
|
48
|
1
|
|
|
|
|
5
|
$self->{fh} = *STDIN; |
|
49
|
|
|
|
|
|
|
} else { |
|
50
|
18
|
|
|
|
|
43
|
my $filesize = file_size($self->{filename}); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
die exception file_is_zero => "File size is zero (and it was not when we read directory listing). Filename: %string filename%", |
|
53
|
|
|
|
|
|
|
filename => $self->{filename} |
|
54
|
18
|
100
|
|
|
|
61
|
unless $filesize; |
|
55
|
|
|
|
|
|
|
|
|
56
|
17
|
|
|
|
|
46
|
$self->{mtime} = file_mtime($self->{filename}); # TODO: how could we assure file not modified when uploading btw? |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
die exception too_many_parts => |
|
59
|
|
|
|
|
|
|
"With current partsize=%d partsize%MiB we will exceed 10000 parts limit for the file %string filename% (file size %size%)", |
|
60
|
|
|
|
|
|
|
partsize => $self->{partsize}, filename => $self->{filename}, size => $filesize |
|
61
|
17
|
100
|
|
|
|
1934
|
if ($filesize / $self->{partsize} > 10000); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
open_file($self->{fh}, $self->{filename}, mode => '<', binary => 1) or |
|
64
|
|
|
|
|
|
|
die exception upload_file_open_error => "Unable to open task file %string filename% for reading, errno=%errno%", |
|
65
|
11
|
50
|
|
|
|
53
|
filename => $self->{filename}, 'ERRNO'; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub on_create |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
16
|
|
|
16
|
0
|
25
|
my ($self) = @_; |
|
72
|
16
|
|
|
|
|
60
|
$self->init_file; |
|
73
|
|
|
|
|
|
|
return state "wait", task "create_upload", { partsize => $self->{partsize}, relfilename => $self->{relfilename}, mtime => $self->{mtime} } => sub { |
|
74
|
16
|
|
|
16
|
|
110
|
my ($args) = @_; |
|
75
|
16
|
50
|
|
|
|
72
|
$self->{upload_id} = $args->{upload_id} or confess; |
|
76
|
16
|
|
|
|
|
72
|
state("done") |
|
77
|
|
|
|
|
|
|
} |
|
78
|
16
|
|
|
|
|
153
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |