#! @PERL@
-# Copyright (c) 2007, 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved.
+# Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 as published
-# by the Free Software Foundation.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
"TAR" => [ $Amanda::Constants::GNUTAR, qw(--ignore-zeros -tf -) ],
"GTAR" => [ $Amanda::Constants::GNUTAR, qw(--ignore-zeros -tf -) ],
"GNUTAR" => [ $Amanda::Constants::GNUTAR, qw(--ignore-zeros -tf -) ],
- "SMBCLIENT" => [ $Amanda::Constants::GNUTAR, qw(--ignore-zeros -tf -) ],
+ "SMBCLIENT" => [ $Amanda::Constants::GNUTAR, qw(-tf -) ],
"PKZIP" => undef,
);
if (!exists $validation_programs{$program}) {
my $all_success = 1;
my @xfer_errs;
my %all_filter;
- my $check_done;
+ my $current_dump;
+ my $recovery_done;
+ my %recovery_params;
my $steps = define_steps
cb_ref => \$finished_cb,
step check_dumpfile => sub {
my ($dump) = @_;
+ $current_dump = $dump;
+
+ $recovery_done = 0;
+ %recovery_params = ();
print "Validating image " . $dump->{hostname} . ":" .
$dump->{diskname} . " dumped " . $dump->{dump_timestamp} . " level ".
delete $all_filter{$src};
$src->remove();
POSIX::close($fd);
- if (!%all_filter and $check_done) {
- $finished_cb->();
+ if (!%all_filter and $recovery_done) {
+ $steps->{'filter_done'}->();
}
} else {
$buffer .= $b;
}
my $xfer = Amanda::Xfer->new([ $xfer_src, @filters, $xfer_dest ]);
- $xfer->start($steps->{'handle_xmsg'});
+ $xfer->start($steps->{'handle_xmsg'}, 0, $current_dump->{'bytes'});
$clerk->start_recovery(
xfer => $xfer,
recovery_cb => $steps->{'recovery_cb'});
};
step recovery_cb => sub {
- my %params = @_;
+ %recovery_params = @_;
+ $recovery_done = 1;
+
+ $steps->{'filter_done'}->() if !%all_filter;
+ };
+ step filter_done => sub {
# distinguish device errors from validation errors
- if (@{$params{'errors'}}) {
+ if (@{$recovery_params{'errors'}}) {
print STDERR "While reading from volumes:\n";
- print STDERR "$_\n" for @{$params{'errors'}};
+ print STDERR "$_\n" for @{$recovery_params{'errors'}};
return $steps->{'quit'}->("validation aborted");
}
if ($err) {
$exit_code = 1;
print STDERR $err, "\n";
- return $clerk->quit(finished_cb => $steps->{'quit1'}) if defined $clerk;;
- return $steps->{'quit1'}->();
+ return $clerk->quit(finished_cb => $finished_cb) if defined $clerk;
+ return $finished_cb->();
}
if ($all_success) {
print "All images successfully validated\n";
} else {
- print "Some images failed to be correclty validated.\n";
+ print "Some images failed to be correctly validated.\n";
$exit_code = 1;
}
- return $clerk->quit(finished_cb => $steps->{'quit1'});
+ return $clerk->quit(finished_cb => $finished_cb);
};
- step quit1 => sub {
- $check_done = 1;
-
- if (!%all_filter) {
- $finished_cb->();
- }
- }
}
main(sub { Amanda::MainLoop::quit(); });