]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl Apply 2.4.3-update-slots.patch to fix #1175. About update slots
authorEric Bollengier <eric@eb.homelinux.org>
Mon, 27 Oct 2008 19:13:49 +0000 (19:13 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 27 Oct 2008 19:13:49 +0000 (19:13 +0000)
     that don't reset InChanger flag when slot is empty.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.4@7920 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/cats/sql_create.c
bacula/src/cats/sql_update.c
bacula/technotes-2.4

index 8415a0274210a0a8c942d2148130c9828741754b..ba428cc5847102447806a5bee1810ad5f346fddc 100644 (file)
@@ -459,14 +459,13 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
               "WHERE MediaId=%d", dt, mr->MediaId);
          stat = UPDATE_DB(jcr, mdb, mdb->cmd);
       }
+      /*
+       * Make sure that if InChanger is non-zero any other identical slot
+       *   has InChanger zero.
+       */
+      db_make_inchanger_unique(jcr, mdb, mr);
    }
 
-   /*
-    * Make sure that if InChanger is non-zero any other identical slot
-    *   has InChanger zero.
-    */
-   db_make_inchanger_unique(jcr, mdb, mr);
-
    db_unlock(mdb);
    return stat;
 }
index d77d025654b039e0f8cf4f580f26e0348109c099..46c62ed97381dbd21392c1780fae190635872c8d 100644 (file)
@@ -445,14 +445,28 @@ void
 db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
    char ed1[50], ed2[50];
-   if (mr->InChanger != 0 && mr->Slot != 0 && mr->StorageId != 0 &&
-       mr->MediaId != 0) {
-      Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE "
-           "Slot=%d AND StorageId=%s AND MediaId!=%s",
-            mr->Slot, 
-            edit_int64(mr->StorageId, ed1), edit_int64(mr->MediaId, ed2));
-      Dmsg1(400, "%s\n", mdb->cmd);
-      UPDATE_DB(jcr, mdb, mdb->cmd);
+   if (mr->InChanger != 0 && mr->Slot != 0 && mr->StorageId != 0) {
+
+       if (mr->MediaId != 0) {
+          Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE "
+               "Slot=%d AND StorageId=%s AND MediaId!=%s",
+               mr->Slot, 
+               edit_int64(mr->StorageId, ed1), edit_int64(mr->MediaId, ed2));
+
+       } else if (mr->VolumeName[0]) { /* We have a volume name */
+          Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE "
+               "Slot=%d AND StorageId=%s AND VolumeName!='%s'",
+               mr->Slot, 
+               edit_int64(mr->StorageId, ed1), mr->VolumeName);
+
+       } else {  /* used by ua_label to reset all volume with this slot */
+          Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE "
+               "Slot=%d AND StorageId=%s",
+               mr->Slot, 
+               edit_int64(mr->StorageId, ed1), mr->VolumeName);          
+       }
+       Dmsg1(100, "%s\n", mdb->cmd);
+       UPDATE_DB(jcr, mdb, mdb->cmd);
    }
 }
 
index 3298db6b30b10d1d8fc287ab3a67b3d4b930d9ce..1e82a143ee1ee2e49914ddef4e1da31d0820998c 100644 (file)
@@ -2,6 +2,9 @@
 
 General:
 Release Version 2.4.3   
+27Oct08
+ebl  Apply 2.4.3-update-slots.patch to fix #1175. About update slots
+     that don't reset InChanger flag when slot is empty.
 10Oct08
 ebl  Apply 2.4.2-cancel-non-running-jobs.patch to be able to cancel
      a non created job faster.