summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2018-12-18 18:33:46 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-12-18 18:33:46 (GMT)
commit249512af92d3f592ae683279c2cd1f54a7c1a726 (patch) (unidiff)
treee71528045c19978bac042c7d6f52cc3485d4feea
parent728992688946fe88173e7cd561456a10c9d23fd8 (diff)
downloadglacier-249512af92d3f592ae683279c2cd1f54a7c1a726.tar.gz
glacier-249512af92d3f592ae683279c2cd1f54a7c1a726.tar.bz2
Fix periodic subcommand
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--lib/App/Glacier/Bre.pm4
-rw-r--r--lib/App/Glacier/Command/Jobs.pm4
-rw-r--r--lib/App/Glacier/Command/Periodic.pm23
3 files changed, 19 insertions, 12 deletions
diff --git a/lib/App/Glacier/Bre.pm b/lib/App/Glacier/Bre.pm
index 3b1d190..cd9fb84 100644
--- a/lib/App/Glacier/Bre.pm
+++ b/lib/App/Glacier/Bre.pm
@@ -26,8 +26,8 @@ sub new {
26 if ($token) { 26 if ($token) {
27 # Overwrite the 'sig' attribute. 27 # Overwrite the 'sig' attribute.
28 # FIXME: The attribute itself is not documented, so this 28 # FIXME: The attribute itself is not documented, so this
29 # this method may fail if the internals of the base class 29 # method may fail if the internals of the base class change
30 # change in its future releases. 30 # in its future releases.
31 # This approach works with Net::Amazon::Glacier 0.15 31 # This approach works with Net::Amazon::Glacier 0.15
32 $self->{sig} = new App::Glacier::Signature($self->{sig}, $token); 32 $self->{sig} = new App::Glacier::Signature($self->{sig}, $token);
33 } 33 }
diff --git a/lib/App/Glacier/Command/Jobs.pm b/lib/App/Glacier/Command/Jobs.pm
index 736d713..5a5f488 100644
--- a/lib/App/Glacier/Command/Jobs.pm
+++ b/lib/App/Glacier/Command/Jobs.pm
@@ -6,6 +6,7 @@ use parent qw(App::Glacier::Command);
6use Carp; 6use Carp;
7use Data::Dumper; 7use Data::Dumper;
8use App::Glacier::Timestamp; 8use App::Glacier::Timestamp;
9use App::Glacier::Job;
9 10
10=head1 NAME 11=head1 NAME
11 12
@@ -136,7 +137,8 @@ sub list {
136 $self->debug(1, "deleting expired $key $vault " . 137 $self->debug(1, "deleting expired $key $vault " .
137 ($descr->{JobDescription} || $descr->{Action}) . 138 ($descr->{JobDescription} || $descr->{Action}) .
138 $descr->{JobId}); 139 $descr->{JobId});
139 $db->delete($key) unless $self->dry_run; 140 App::Glacier::Job->fromdb($self, $vault, $key, $res)->delete()
141 unless $self->dry_run;
140 return; 142 return;
141 } else { 143 } else {
142 $self->error("can't describe job $descr->{JobId}: ", 144 $self->error("can't describe job $descr->{JobId}: ",
diff --git a/lib/App/Glacier/Command/Periodic.pm b/lib/App/Glacier/Command/Periodic.pm
index 51c9718..5a4dc2a 100644
--- a/lib/App/Glacier/Command/Periodic.pm
+++ b/lib/App/Glacier/Command/Periodic.pm
@@ -42,30 +42,35 @@ sub run {
42 my $vault = $descr->{VaultARN}; 42 my $vault = $descr->{VaultARN};
43 $vault =~ s{.*:vaults/}{}; 43 $vault =~ s{.*:vaults/}{};
44 44
45 return if $descr->{Completed}; 45 my $completed = $descr->{Completed};
46 46
47 $self->debug(2, "$descr->{JobId} $descr->{Action} $vault"); 47 $self->debug(2, "$descr->{JobId} $descr->{Action} $vault");
48 if ($descr->{StatusCode} eq 'Failed') { 48 if ($descr->{StatusCode} eq 'Failed') {
49 $self->debug(1, "deleting failed $key $vault " . 49 $self->debug(1,
50 ($descr->{JobDescription} || $descr->{Action}) . 50 "deleting failed $key $vault "
51 $descr->{JobId}); 51 . ($descr->{JobDescription} || $descr->{Action})
52 . ' '
53 . $descr->{JobId});
52 $db->delete($key) unless $self->dry_run; 54 $db->delete($key) unless $self->dry_run;
53 } 55 }
54 56
55 my $res = $self->glacier->Describe_job($vault, $descr->{JobId}); 57 my $res = $self->glacier->Describe_job($vault, $descr->{JobId});
56 if ($self->glacier->lasterr) { 58 if ($self->glacier->lasterr) {
57 if ($self->glacier->lasterr('code') == 404) { 59 if ($self->glacier->lasterr('code') == 404) {
58 $self->debug(1, "deleting expired $key $vault " . 60 $self->debug(1,
59 ($descr->{JobDescription} || $descr->{Action}) . 61 "deleting expired $key $vault "
60 $descr->{JobId}); 62 . ($descr->{JobDescription} || $descr->{Action})
61 $db->delete($key) unless $self->dry_run; 63 . ' '
64 . $descr->{JobId});
65 App::Glacier::Job->fromdb($self, $vault, $key, $res)->delete()
66 unless $self->dry_run;
62 } else { 67 } else {
63 $self->error("can't describe job $descr->{JobId}: ", 68 $self->error("can't describe job $descr->{JobId}: ",
64 $self->glacier->last_error_message); 69 $self->glacier->last_error_message);
65 } 70 }
66 } elsif (ref($res) ne 'HASH') { 71 } elsif (ref($res) ne 'HASH') {
67 croak "describe_job returned wrong datatype (".ref($res).") for \"$descr->{JobId}\""; 72 croak "describe_job returned wrong datatype (".ref($res).") for \"$descr->{JobId}\"";
68 } else { 73 } elsif ($res->{Completed} ne $completed) {
69 $self->debug(2, $res->{StatusCode}); 74 $self->debug(2, $res->{StatusCode});
70 if ($res->{Completed} && $res->{StatusCode} eq 'Succeeded') { 75 if ($res->{Completed} && $res->{StatusCode} eq 'Succeeded') {
71 $self->debug(1, "$descr->{JobId}: processing $descr->{Action} for $vault"); 76 $self->debug(1, "$descr->{JobId}: processing $descr->{Action} for $vault");

Return to:

Send suggestions and report system problems to the System administrator.