summaryrefslogtreecommitdiffabout
path: root/lib/App/Glacier/Command/Periodic.pm
Side-by-side diff
Diffstat (limited to 'lib/App/Glacier/Command/Periodic.pm') (more/less context) (ignore whitespace changes)
-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;
use Data::Dumper;
use File::Basename;
use App::Glacier::Job;
+use App::Glacier::Command::Get;
=head1 NAME
@@ -38,39 +39,10 @@ sub run {
my $db = $self->jobdb();
$db->foreach(sub {
- my ($key, $descr) = @_;
- my $vault = $descr->{VaultARN};
- $vault =~ s{.*:vaults/}{};
+ my ($key, $descr, $vault) = @_;
- my $completed = $descr->{Completed};
-
- $self->debug(2, "$descr->{JobId} $descr->{Action} $vault");
- if ($descr->{StatusCode} eq 'Failed') {
- $self->debug(1,
- "deleting failed $key $vault "
- . ($descr->{JobDescription} || $descr->{Action})
- . ' '
- . $descr->{JobId});
- $db->delete($key) unless $self->dry_run;
- }
-
- my $res = $self->glacier->Describe_job($vault, $descr->{JobId});
- if ($self->glacier->lasterr) {
- if ($self->glacier->lasterr('code') == 404) {
- $self->debug(1,
- "deleting expired $key $vault "
- . ($descr->{JobDescription} || $descr->{Action})
- . ' '
- . $descr->{JobId});
- App::Glacier::Job->fromdb($self, $vault, $key, $res)->delete()
- unless $self->dry_run;
- } else {
- $self->error("can't describe job $descr->{JobId}: ",
- $self->glacier->last_error_message);
- }
- } elsif (ref($res) ne 'HASH') {
- croak "describe_job returned wrong datatype (".ref($res).") for \"$descr->{JobId}\"";
- } elsif ($res->{Completed} ne $completed) {
+ my $res = $self->check_job($key, $descr, $vault);
+ if ($res && $res->{Completed} ne $descr->{Completed}) {
$self->debug(2, $res->{StatusCode});
if ($res->{Completed} && $res->{StatusCode} eq 'Succeeded') {
$self->debug(1, "$descr->{JobId}: processing $descr->{Action} for $vault");
@@ -86,8 +58,8 @@ sub run {
$res->{ArchiveId});
$self->touchdir(dirname($localname));
- require App::Glacier::Command::Get;
my $get = clone App::Glacier::Command::Get($self);
+ $get->option(quiet => 1);
$get->download($job, $localname);
}
}

Return to:

Send suggestions and report system problems to the System administrator.