Nathan,

Thanks for reporting the issue.
I committed the attached patch.

Jean-LouisOn 15/03/17 06:27 PM, Nathan Stratton Treadway wrote:
> Summary: if the "tapelist" file doesn't exist, amlabel creates the file
> but doesn't populate it.  (Again, this is using Amanda 3.4.3.)
>
> (In the following examples, I delete the 00000.TESTBACKUP-01 file out of
> the vtape slot1 directory before each test run, so the only difference
> is the existence of the "tapelist" file.)
>
> First test: if tapelist doesn't exist beforehand, amlabel creates it,
> but the line for the newly-labled tape isn't written to it:
> =====
> # rm tapelist
> # cat tapelist
> cat: tapelist: No such file or directory
>
> # su backup -c "amlabel TestBackup TESTBACKUP-01 slot 1"
> Reading label...
> Found an empty tape.
> Writing label 'TESTBACKUP-01'...
> Checking label...
> Success!
> # cat tapelist
> # ls -l tapelist
> -rw------- 1 backup backup 0 Mar 15 17:58 tapelist
> =====
>
> (The label is in fact written to the vtape, so the end result a labeled
> vtape that isn't listed in the tapelist file, as shown if I repeat the
> label command again immediately after the previous run:
> =====
> # su backup -c "amlabel TestBackup TESTBACKUP-01 slot 1"
> Reading label...
> Found label 'TESTBACKUP-01' but it is not in the tapelist file.
> Not writing label.
> Not writing label.
> =====
> )
>
>
> However, if I create an empty tapelist file first, the tape-line is
> written to the file as expected:
> =====
> # rm tapelist
> # cat tapelist
> cat: tapelist: No such file or directory
> # touch tapelist
>
> # su backup -c "amlabel TestBackup TESTBACKUP-01 slot 1"
> Reading label...
> Found an empty tape.
> Writing label 'TESTBACKUP-01'...
> Checking label...
> Success!
> # cat tapelist
> 0 TESTBACKUP-01 reuse BLOCKSIZE:32 POOL:TestBackup STORAGE:TestBackup 
> CONFIG:TestBackup
> =====
>
> At first glance, the amlabel.20170315*.debug files for the two runs
> appear identical (e.g. both are 33 lines and 449 words long, according
> to "wc"), so I don't believe the log gives any indication that something
> went wrong.
>
> (Jean-Louis,) let me know if the cause of this problem is immediately
> obvious to you or if it would help for me to do some debugging the
> Tapelist.pm code.
>
> Thanks.
>
>
>                                                       Nathan
>
> ----------------------------------------------------------------------------
> Nathan Stratton Treadway  -  natha...@ontko.com  -  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
>
This message is the property of CARBONITE, INC. and may contain confidential or 
privileged information.
If this message has been delivered to you by mistake, then do not copy or 
deliver this message to anyone.  Instead, destroy it and notify me by reply 
e-mail
diff --git a/perl/Amanda/Tapelist.swg b/perl/Amanda/Tapelist.swg
index 99f1164..e846eb0 100644
--- a/perl/Amanda/Tapelist.swg
+++ b/perl/Amanda/Tapelist.swg
@@ -309,7 +309,12 @@ sub _read_tapelist {
     $self->{'tle_hash_label'} = undef;
     $self->{'tle_hash_barcode'} = undef;
     my $linenum = 0;
-    open(my $fh, "<", $self->{'filename'}) or return undef;
+    my $fh;
+    if (!open($fh, "<", $self->{'filename'})) {
+	$self->{'tles'} = [];
+	return undef;
+    }
+
     while (my $line = <$fh>) {
 	$linenum++;
 	my ($datestamp, $label, $reuse, $barcode, $meta, $blocksize, $pool, $storage, $config, $comment)

Reply via email to