Imported Upstream version 3.3.3
[debian/amanda] / perl / Amanda / Changer / single.pm
index 0edc07dc9dbd118ff62121a5a3bf3cb7eda418a4..8417d02a0e5a0034544445f28d1c14dfecd42a57 100644 (file)
@@ -1,8 +1,9 @@
-# Copyright (c) 2008,2009,2010 Zmanda, Inc.  All Rights Reserved.
+# Copyright (c) 2008-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
@@ -20,6 +21,7 @@ package Amanda::Changer::single;
 
 use strict;
 use warnings;
+use Carp;
 use vars qw( @ISA );
 @ISA = qw( Amanda::Changer );
 
@@ -77,7 +79,7 @@ sub load {
 
     return if $self->check_error($params{'res_cb'});
 
-    die "no res_cb supplied" unless (exists $params{'res_cb'});
+    confess "no res_cb supplied" unless (exists $params{'res_cb'});
 
     if ($self->{'reserved'}) {
        return $self->make_error("failed", $params{'res_cb'},
@@ -166,6 +168,10 @@ sub do_release {
     my $self = shift;
     my %params = @_;
 
+    $self->{'device'}->eject() if (exists $self->{'device'} and
+                                  exists $params{'eject'} and
+                                  $params{'eject'});
+
     $self->{'chg'}->{'reserved'} = 0;
 
     # unref the device, for good measure