]> git.sur5r.net Git - bacula/bacula/commitdiff
Tweak add error checks
authorKern Sibbald <kern@sibbald.com>
Sat, 13 Feb 2010 11:34:08 +0000 (12:34 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 13 Feb 2010 11:34:08 +0000 (12:34 +0100)
bacula/src/cats/sql_create.c
bacula/src/dird/dird.c

index 736db4420f1a00568e6dc30f0c8ccd3b0417d29b..a106fe888e84e394dd826f426a1b78816d43ed8e 100644 (file)
@@ -285,6 +285,7 @@ bool db_create_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr)
 
    sr->StorageId = 0;
    sr->created = false;
+   /* Check if it already exists */
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       mdb->num_rows = sql_num_rows(mdb);
       /* If more than one, report error, but return first row */
index c68e4cb3a909a3fafb17651c9b90217a97e76399..a34fe4a933099abc954a11211bb63881864a03f4 100644 (file)
@@ -1021,11 +1021,19 @@ static bool check_catalog(cat_op mode)
          }
          bstrncpy(sr.Name, store->name(), sizeof(sr.Name));
          sr.AutoChanger = store->autochanger;
-         db_create_storage_record(NULL, db, &sr);
+         if (!db_create_storage_record(NULL, db, &sr)) {
+            Jmsg(NULL, M_FATAL, 0, _("Could not create storage record for %s\n"), 
+                 store->name());
+            OK = false;
+         }
          store->StorageId = sr.StorageId;   /* set storage Id */
          if (!sr.created) {                 /* if not created, update it */
             sr.AutoChanger = store->autochanger;
-            db_update_storage_record(NULL, db, &sr);
+            if (!db_update_storage_record(NULL, db, &sr)) {
+               Jmsg(NULL, M_FATAL, 0, _("Could not update storage record for %s\n"),
+                    store->name());
+               OK = false;
+            }
          }
 
          /* tls_require implies tls_enable */