Imported Upstream version 3.3.3
[debian/amanda] / perl / Amanda / ScanInventory.pm
index d47f67510a89251635318189451ce261593da63f..235d2fb9047d33c811f4d21023fe3977e1e2bd0f 100644 (file)
@@ -1,8 +1,9 @@
-# Copyright (c) 2010 Zmanda, Inc.  All Rights Reserved.
+# 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
@@ -264,10 +265,12 @@ sub _scan {
            $res->{device}->status == $DEVICE_STATUS_SUCCESS) {
            $label = $res->{device}->volume_label;
        }
+       my $relabeled = !defined($label) || $label !~ /$self->{'labelstr'}/;
        $self->_user_msg(slot_result => 1,
                         slot => $slot_scanned,
                         label => $label,
                         err  => $err,
+                        relabeled => $relabeled,
                         res  => $res);
        if ($res) {
            my $f_type;
@@ -500,7 +503,7 @@ sub _scan {
            return $result_cb->($err, $res);
        }
        $label = $res->{'device'}->volume_label;
-       if (!defined $label) {
+       if (!defined($label) || $label !~ /$self->{'labelstr'}/) {
            $res->get_meta_label(finished_cb => $steps->{'got_meta_label'});
            return;
        }
@@ -567,12 +570,14 @@ sub volume_is_labelable {
                             err          => $sl->{'device_error'},
                             slot         => $slot);
        return 0;
-    } elsif ($dev_status & $DEVICE_STATUS_SUCCESS and
+    } elsif ($dev_status == $DEVICE_STATUS_SUCCESS and
             $f_type == $Amanda::Header::F_TAPESTART and
             $label !~ /$self->{'labelstr'}/) {
        if (!$autolabel->{'other_config'}) {
            $self->_user_msg(slot_result  => 1,
-                            other_config => 1,
+                            label        => $label,
+                            labelstr     => $self->{'labelstr'},
+                            does_not_match_labelstr => 1,
                             slot         => $slot);
            return 0;
        }