Imported Upstream version 3.3.3
[debian/amanda] / perl / Amanda / Taper / Scan / lexical.pm
index 44c2b0e1bcf2d0e3ea257eb76f3323ed667106e7..dfd2bab0cffd244431ad2d4f1c4dff9fc8b03e95 100644 (file)
@@ -1,8 +1,9 @@
 # Copyright (c) 2010-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
@@ -149,17 +150,25 @@ sub analyze {
                push @reusable, $sl;
            } else {
                my $vol_tle = $self->{'tapelist'}->lookup_tapelabel($sl->{'label'});
-               if ($vol_tle) {
+               if ($vol_tle && $sl->{'label'} =~ /$self->{'labelstr'}/) {
                    if ($vol_tle->{'datestamp'} eq '0') {
                        push @new_labeled, $sl;
                    }
                } elsif ($self->volume_is_labelable($sl)) {
+                   $sl->{'label'} = $self->{'chg'}->make_new_tape_label(
+                                       barcode => $sl->{'barcode'},
+                                       slot => $sl->{'slot'},
+                                       meta => $sl->{'meta'});
                    $first_new_volume = $sl if !$first_new_volume;
                    $new_volume = $sl if $current && !$new_volume;
                    push @new_volume, $sl;
                }
            }
        } elsif ($self->volume_is_labelable($sl)) {
+           $sl->{'label'} = $self->{'chg'}->make_new_tape_label(
+                                       barcode => $sl->{'barcode'},
+                                       slot => $sl->{'slot'},
+                                       meta => $sl->{'meta'});
            $first_new_volume = $sl if !$first_new_volume;
            $new_volume = $sl if $current && !$new_volume;
            push @new_volume, $sl;
@@ -203,10 +212,6 @@ sub analyze {
     }
 
     for my $sl (@new_volume) {
-       $sl->{'label'} = $self->{'chg'}->make_new_tape_label(
-                                       barcode => $sl->{'barcode'},
-                                       slot => $sl->{'slot'},
-                                       meta => $sl->{'meta'});
        $new_volume = $sl if defined $last_label and
                             $new_volume->{'label'} ne $sl->{'label'} and
                             (($sl->{'label'} gt $last_label and