diff options
Diffstat (limited to 'lib/App/Glacier/Command.pm')
-rw-r--r-- | lib/App/Glacier/Command.pm | 43 |
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 { | |||
164 | 164 | ||
165 | sub option { | ||
166 | my ($self, $opt, $val) = @_; | ||
167 | if (defined($val)) { | ||
168 | $self->{_options}{$opt} = $val; | ||
169 | } | ||
170 | return $self->{_options}{$opt}; | ||
171 | } | ||
172 | |||
165 | sub touchdir { | 173 | sub touchdir { |
@@ -278,2 +286,37 @@ sub archive_cache_filename { | |||
278 | 286 | ||
287 | sub check_job { | ||
288 | my ($self, $key, $descr, $vault) = @_; | ||
289 | |||
290 | $self->debug(2, "$descr->{JobId} $descr->{Action} $vault"); | ||
291 | if ($descr->{StatusCode} eq 'Failed') { | ||
292 | $self->debug(1, | ||
293 | "deleting failed $key $vault " | ||
294 | . ($descr->{JobDescription} || $descr->{Action}) | ||
295 | . ' ' | ||
296 | . $descr->{JobId}); | ||
297 | $self->jobdb()->delete($key) unless $self->dry_run; | ||
298 | return; | ||
299 | } | ||
300 | |||
301 | my $res = $self->glacier->Describe_job($vault, $descr->{JobId}); | ||
302 | if ($self->glacier->lasterr) { | ||
303 | if ($self->glacier->lasterr('code') == 404) { | ||
304 | $self->debug(1, | ||
305 | "deleting expired $key $vault " | ||
306 | . ($descr->{JobDescription} || $descr->{Action}) | ||
307 | . ' ' | ||
308 | . $descr->{JobId}); | ||
309 | App::Glacier::Job->fromdb($self, $vault, $key, $res)->delete() | ||
310 | unless $self->dry_run; | ||
311 | } else { | ||
312 | $self->error("can't describe job $descr->{JobId}: ", | ||
313 | $self->glacier->last_error_message); | ||
314 | } | ||
315 | return; | ||
316 | } elsif (ref($res) ne 'HASH') { | ||
317 | croak "describe_job returned wrong datatype (".ref($res).") for \"$descr->{JobId}\""; | ||
318 | } | ||
319 | return $res; | ||
320 | } | ||
321 | |||
279 | 1; | 322 | 1; |