summaryrefslogtreecommitdiffabout
path: root/lib/App/Glacier/Command.pm
Side-by-side diff
Diffstat (limited to 'lib/App/Glacier/Command.pm') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/App/Glacier/Command.pm43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/App/Glacier/Command.pm b/lib/App/Glacier/Command.pm
index 7178a75..1f9a130 100644
--- a/lib/App/Glacier/Command.pm
+++ b/lib/App/Glacier/Command.pm
@@ -164,2 +164,10 @@ sub clone {
+sub option {
+ my ($self, $opt, $val) = @_;
+ if (defined($val)) {
+ $self->{_options}{$opt} = $val;
+ }
+ return $self->{_options}{$opt};
+}
+
sub touchdir {
@@ -278,2 +286,37 @@ sub archive_cache_filename {
+sub check_job {
+ my ($self, $key, $descr, $vault) = @_;
+
+ $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});
+ $self->jobdb()->delete($key) unless $self->dry_run;
+ return;
+ }
+
+ 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);
+ }
+ return;
+ } elsif (ref($res) ne 'HASH') {
+ croak "describe_job returned wrong datatype (".ref($res).") for \"$descr->{JobId}\"";
+ }
+ return $res;
+}
+
1;

Return to:

Send suggestions and report system problems to the System administrator.