File Coverage

lib/App/MtAws/QueueJob/MultipartFinish.pm
Criterion Covered Total %
statement 30 30 100.0
branch 10 10 100.0
condition n/a
subroutine 9 9 100.0
pod 0 2 0.0
total 49 51 96.0


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::MultipartFinish;
22              
23             our $VERSION = '1.114_2';
24              
25 10     10   619 use strict;
  10         14  
  10         260  
26 10     10   37 use warnings;
  10         13  
  10         254  
27 10     10   37 use Carp;
  10         14  
  10         552  
28              
29 10     10   45 use App::MtAws::QueueJobResult;
  10         10  
  10         886  
30 10     10   79 use App::MtAws::Exceptions;
  10         17  
  10         583  
31 10     10   57 use base 'App::MtAws::QueueJob';
  10         15  
  10         2619  
32              
33             sub init
34             {
35 27     27 0 43 my ($self) = @_;
36 27 100       197 $self->{upload_id}||confess;
37 25 100       264 $self->{filesize}||confess;
38 23 100       118 defined($self->{mtime})||confess;
39 22 100       114 defined($self->{relfilename})||confess;
40 21 100       178 $self->{th}||confess;
41 19         33 return $self;
42             }
43              
44             sub on_default
45             {
46 16     16 0 25 my ($self) = @_;
47              
48 16         82 $self->{th}->calc_tree();
49 16         106 $self->{final_hash} = $self->{th}->get_final_hash();
50             return state "wait", task "finish_upload", {
51             upload_id => $self->{upload_id},
52             filesize => $self->{filesize},
53             mtime => $self->{mtime},
54             relfilename => $self->{relfilename},
55             final_hash => $self->{final_hash}
56 16     16   104 } => sub { state "done" };
  16         62  
57             }
58              
59             1;