aboutsummaryrefslogtreecommitdiff
path: root/lib/App/Glacier/Command/Periodic.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/Glacier/Command/Periodic.pm')
-rw-r--r--lib/App/Glacier/Command/Periodic.pm38
1 files changed, 5 insertions, 33 deletions
diff --git a/lib/App/Glacier/Command/Periodic.pm b/lib/App/Glacier/Command/Periodic.pm
index 5a4dc2a..39a2d7a 100644
--- a/lib/App/Glacier/Command/Periodic.pm
+++ b/lib/App/Glacier/Command/Periodic.pm
@@ -7,6 +7,7 @@ use Carp;
7use Data::Dumper; 7use Data::Dumper;
8use File::Basename; 8use File::Basename;
9use App::Glacier::Job; 9use App::Glacier::Job;
10use App::Glacier::Command::Get;
10 11
11=head1 NAME 12=head1 NAME
12 13
@@ -38,39 +39,10 @@ sub run {
38 39
39 my $db = $self->jobdb(); 40 my $db = $self->jobdb();
40 $db->foreach(sub { 41 $db->foreach(sub {
41 my ($key, $descr) = @_; 42 my ($key, $descr, $vault) = @_;
42 my $vault = $descr->{VaultARN};
43 $vault =~ s{.*:vaults/}{};
44 43
45 my $completed = $descr->{Completed}; 44 my $res = $self->check_job($key, $descr, $vault);
46 45 if ($res && $res->{Completed} ne $descr->{Completed}) {
47 $self->debug(2, "$descr->{JobId} $descr->{Action} $vault");
48 if ($descr->{StatusCode} eq 'Failed') {
49 $self->debug(1,
50 "deleting failed $key $vault "
51 . ($descr->{JobDescription} || $descr->{Action})
52 . ' '
53 . $descr->{JobId});
54 $db->delete($key) unless $self->dry_run;
55 }
56
57 my $res = $self->glacier->Describe_job($vault, $descr->{JobId});
58 if ($self->glacier->lasterr) {
59 if ($self->glacier->lasterr('code') == 404) {
60 $self->debug(1,
61 "deleting expired $key $vault "
62 . ($descr->{JobDescription} || $descr->{Action})
63 . ' '
64 . $descr->{JobId});
65 App::Glacier::Job->fromdb($self, $vault, $key, $res)->delete()
66 unless $self->dry_run;
67 } else {
68 $self->error("can't describe job $descr->{JobId}: ",
69 $self->glacier->last_error_message);
70 }
71 } elsif (ref($res) ne 'HASH') {
72 croak "describe_job returned wrong datatype (".ref($res).") for \"$descr->{JobId}\"";
73 } elsif ($res->{Completed} ne $completed) {
74 $self->debug(2, $res->{StatusCode}); 46 $self->debug(2, $res->{StatusCode});
75 if ($res->{Completed} && $res->{StatusCode} eq 'Succeeded') { 47 if ($res->{Completed} && $res->{StatusCode} eq 'Succeeded') {
76 $self->debug(1, "$descr->{JobId}: processing $descr->{Action} for $vault"); 48 $self->debug(1, "$descr->{JobId}: processing $descr->{Action} for $vault");
@@ -86,8 +58,8 @@ sub run {
86 $res->{ArchiveId}); 58 $res->{ArchiveId});
87 $self->touchdir(dirname($localname)); 59 $self->touchdir(dirname($localname));
88 60
89 require App::Glacier::Command::Get;
90 my $get = clone App::Glacier::Command::Get($self); 61 my $get = clone App::Glacier::Command::Get($self);
62 $get->option(quiet => 1);
91 $get->download($job, $localname); 63 $get->download($job, $localname);
92 } 64 }
93 } 65 }

Return to:

Send suggestions and report system problems to the System administrator.