diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-03-07 22:47:13 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-03-07 22:47:13 +0200 |
commit | 31d5e3b6439608b399a74695b9997d62af85cc9d (patch) | |
tree | 35223a7e5ee16488370b1883099273903f49a71a /lib/App/Beam.pm | |
parent | 991ff90bc8dee27023fd96adeda615f4f37ad0e0 (diff) | |
download | beam-31d5e3b6439608b399a74695b9997d62af85cc9d.tar.gz beam-31d5e3b6439608b399a74695b9997d62af85cc9d.tar.bz2 |
Store backup results for each backup item individually
* lib/App/Beam.pm (RESULT_*): New constants.
(set_result): Take 3 arguments.
* lib/App/Beam/Backend/Tar.pm (backup): Capture stderr.
* lib/App/Beam/Backup.pm: Check number of command line arguments.
* lib/App/Beam/Command.pm (set_logger): New method.
* lib/App/Beam/List.pm: New command line option --verbose.
Diffstat (limited to 'lib/App/Beam.pm')
-rw-r--r-- | lib/App/Beam.pm | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/App/Beam.pm b/lib/App/Beam.pm index 6a654ca..b7e004e 100644 --- a/lib/App/Beam.pm +++ b/lib/App/Beam.pm @@ -11,6 +11,10 @@ use POSIX qw(strftime floor); require App::Beam::Config; our @ISA = qw(App::Beam::Config); +our @EXPORT_OK = qw(RESULT_PENDING RESULT_SUCCESS RESULT_FAILURE); +our %EXPORT_TAGS = ( + result => [ qw(RESULT_PENDING RESULT_SUCCESS RESULT_FAILURE) ] +); my $default_config_file = '/etc/beam.conf'; @@ -251,6 +255,12 @@ sub abend { exit($code); } +use constant { + RESULT_PENDING => 0, + RESULT_SUCCESS => 1, + RESULT_FAILURE => 2 +}; + # Locks the statfile and retrieves data from it into {status} sub lock { my $self = shift; @@ -273,7 +283,7 @@ sub lock { } my ($cycle, $round, $level) = $self->compute_triplet(1); unshift @{$self->{status}}, { timestamp => time(), - result => 'PENDING', + result => RESULT_PENDING, cycle => $cycle, round => $round, level => $level }; @@ -284,7 +294,7 @@ sub unlock { my ($self) = @_; croak "unlock without lock" unless defined $self->{statfd}; $self->debug(1, "saving state: ".$self->status('result')); - if (!$self->{dry_run} && $self->status('result') ne 'PENDING') { + if (!$self->{dry_run} && $self->status('result') != RESULT_PENDING) { seek($self->{statfd}, 0, SEEK_SET); truncate($self->{statfd}, 0); nstore_fd($self->{status}, $self->{statfd}); @@ -353,8 +363,10 @@ sub result { } sub set_result { - my ($self, $result) = @_; - $self->{status}[0]{result} = $result; + my ($self, $item, $result) = @_; + $self->{status}[0]{detail}{$item} = $result; + $self->{status}[0]{result} = $result + unless $self->{status}[0]{result} == RESULT_FAILURE; } sub format_name { |