some fixes to Vault.pm (Amanda 3.4)

Nathan Stratton Treadway <[email protected]> Thu, 21 Sep 2017 15:06:04 -0400
Newsgroups gmane.comp.archivers.amanda.devel
Message-ID <[email protected]>
I was experimenting with "amvault" (Amanda 3.4.5), and noticed a few
issues, which I have attempted to fix in the attached patch to Vault.pm:

* when run on a tty, the progress messages say "nnnnnn KB", but nnnnnn
  is actually in bytes; also, add the word "written" to make it clearer
  what the message means.

* the 5s time period mentioned in the comment about creating a timer
  callback seems to be obsolete.

* The value of the $self->{'quiet'} parameter does not appear to be used
  anywhere in the Vault.pm code.  For a quick fix, this patch makes --quiet
  suppress the interactive "bytes written" progress messages.

							Nathan


----------------------------------------------------------------------------
Nathan Stratton Treadway  -  [email protected]  -  Mid-Atlantic region
Ray Ontko & Co.  -  Software consulting services  -   http://www.ontko.com/
 GPG Key: http://www.ontko.com/~nathanst/gpg_key.txt   ID: 1023D/ECFB6239
 Key fingerprint = 6AD8 485E 20B9 5C71 231C  0C32 15F3 ADCD ECFB 6239
Vault.pm_patch_20170921.diff (text/x-diff, 1.4 KB)
--- /usr/lib/x86_64-linux-gnu/amanda/perl/Amanda/Vault.pm_dist_3.4.5	2017-06-08 20:59:45.000000000 -0400
+++ /usr/lib/x86_64-linux-gnu/amanda/perl/Amanda/Vault.pm	2017-09-21 00:23:57.821972020 -0400
@@ -52,7 +52,7 @@
     } elsif ($self->{'code'} == 2500007) {
 	return "No dumps found";
     } elsif ($self->{'code'} == 2500008) {
-	return "$self->{'bytes_written'} KB";
+	return "$self->{'bytes_written'} bytes written";
     } elsif ($self->{'code'} == 2500010) {
 	return "No import/export slots available; skipping export";
     } elsif ($self->{'code'} == 2500011) {
@@ -294,7 +294,8 @@
     $self->amdump_log("status file $self->{'id'}:" .  "$self->{status_filename}");
     print {$self->{status_fh}} "0";
 
-    # create timer callback, firing every 5s (=5000msec)
+    # create timer callback, firing every 'delay' ms (as specified by caller
+    # when this Vault was created))
     if (!$self->{'timer'}) {
 	$self->{timer} = Amanda::MainLoop::timeout_source($self->{'delay'});
 	$self->{timer}->set_callback(sub {
@@ -304,7 +305,9 @@
 		print {$self->{status_fh}} $size, '     ';
 		$self->{status_fh}->flush();
 
-		if ($self->{'is_tty'}) {
+		# print progress message if we're running on a tty,
+		# unless --quiet option was given.
+		if ($self->{'is_tty'} && !$self->{'quiet'}) {
 		    $self->user_msg(Amanda::Vault::Message->new(
 				source_filename => __FILE__,
 				source_line     => __LINE__,