]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/autochanger.c
Fix broken editing code
[bacula/bacula] / bacula / src / stored / autochanger.c
index b6225613356fac309f7002752ebb99e71494c173..3cec6dd19d622c99441fb8c4e9d8cb0ef4cabc68 100644 (file)
@@ -20,7 +20,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Bacula® is a registered trademark of John Walker.
+   Bacula® is a registered trademark of Kern Sibbald.
    The licensor of Bacula is the Free Software Foundation Europe
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
@@ -378,7 +378,9 @@ bool unload_autochanger(DCR *dcr, int loaded)
       free_volume(dev);            /* Free any volume associated with this drive */
       free_pool_memory(changer);
    }
-   dev->clear_unload();
+   if (ok) {
+      dev->clear_unload();
+   }
    return ok;
 }
 
@@ -425,8 +427,8 @@ static bool unload_other_drive(DCR *dcr, int slot)
       break;
    }
    if (dev->is_busy()) {
-      Jmsg(dcr->jcr, M_WARNING, 0, _("Volume \"%s\" is in use by device %s\n"),
-           dcr->VolumeName, dev->print_name());
+      Jmsg(dcr->jcr, M_WARNING, 0, _("Volume \"%s\" wanted on %s is in use by device %s\n"),
+           dcr->VolumeName, dcr->dev->print_name(), dev->print_name());
       Dmsg4(100, "Vol %s for dev=%s is busy dev=%s slot=%d\n",
            dcr->VolumeName, dcr->dev->print_name(), dev->print_name(), dev->get_slot());
       Dmsg2(100, "num_writ=%d reserv=%d\n", dev->num_writers, dev->num_reserved());
@@ -453,13 +455,12 @@ bool unload_dev(DCR *dcr, DEVICE *dev)
 
    save_dev = dcr->dev;               /* save dcr device */
    dcr->dev = dev;                    /* temporarily point dcr at other device */
-   save_slot = dcr->VolCatInfo.Slot;
 
    if (dev->get_slot() <= 0 && get_autochanger_loaded_slot(dcr) <= 0) {
-      dcr->VolCatInfo.Slot = save_slot;
       dcr->dev = save_dev;
       return false;
    }
+   save_slot = dcr->VolCatInfo.Slot;
    dcr->VolCatInfo.Slot = dev->get_slot();
 
    dev->dlock();
@@ -497,7 +498,9 @@ bool unload_dev(DCR *dcr, DEVICE *dev)
       Dmsg2(100, "Slot %d unloaded %s\n", dev->get_slot(), dev->print_name());
       dev->set_slot(0);           /* nothing loaded */
    }
-   dev->clear_unload();
+   if (ok) {
+      dev->clear_unload();
+   }
    unlock_changer(dcr);
 
    dev->dunlock();