aboutsummaryrefslogtreecommitdiff
path: root/lib/App/Glacier/Command.pm
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-12-19 14:35:49 +0200
committerSergey Poznyakoff <gray@gnu.org>2018-12-19 14:55:09 +0200
commitea2c058ce96484937fcfe52dc7382a461a9d72e3 (patch)
treeae86e1115c3ef91bc03d2cfcb7df4f7ff8d19ce9 /lib/App/Glacier/Command.pm
parent249512af92d3f592ae683279c2cd1f54a7c1a726 (diff)
downloadglacier-ea2c058ce96484937fcfe52dc7382a461a9d72e3.tar.gz
glacier-ea2c058ce96484937fcfe52dc7382a461a9d72e3.tar.bz2
Bugfixes.
* lib/App/Glacier/Command.pm (option,check_job): New methods. * lib/App/Glacier/Command/Get.pm: Rewrite debug messages (fixes temporary solution in 6c6dab5d). * lib/App/Glacier/Command/Jobs.pm: Rewrite the db->foreach sub. * lib/App/Glacier/Command/Periodic.pm: Likewise. * lib/App/Glacier/DB/GDBM.pm (CLONE_SKIP): New method. * lib/App/Glacier/Job.pm: Overload the "" operator. * lib/App/Glacier/Roster.pm (foreach): Overload method.
Diffstat (limited to 'lib/App/Glacier/Command.pm')
-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
@@ -162,6 +162,14 @@ sub clone {
$self
}
+sub option {
+ my ($self, $opt, $val) = @_;
+ if (defined($val)) {
+ $self->{_options}{$opt} = $val;
+ }
+ return $self->{_options}{$opt};
+}
+
sub touchdir {
my ($self, $dir) = @_;
unless (-d $dir) {
@@ -276,4 +284,39 @@ sub archive_cache_filename {
$archive_id);
}
+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.