From c431d5446761e2ae16db6e56f51f3659becc9e4b Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Mon, 27 Oct 2008 19:24:23 +0000 Subject: [PATCH] ebl Fix #1175 About update slots that don't reset InChanger flag when slot is empty. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7921 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/cats/sql_create.c | 11 +++++------ bacula/src/cats/sql_update.c | 30 ++++++++++++++++++++++-------- bacula/technotes-2.5 | 2 ++ 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index d3ba6f89b4..998ccc6bf2 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -457,14 +457,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; } diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index 521a9cc8ad..2b4ef29f59 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -473,14 +473,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) { + 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); } } diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 7f16dbf919..40ebfd943f 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -11,6 +11,8 @@ mixed priorities General: 27Oct08 +ebl Fix #1175 About update slots that don't reset InChanger flag when + slot is empty. ebl Fix #1173 where prune_volume() returns a volume from the scratch. 25Oct08 kes Remove jobq.c constraint that read and write SD must be -- 2.39.5