]> 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)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 2 Aug 2010 14:49:29 +0000 (16:49 +0200)
bacula/src/cats/sql_create.c
bacula/src/dird/dird.c

index a635861e413cc2126bd9d9ce8430f6b6310ac983..5290b99e55dc26179c07d72fccce4fe0abb5e6de 100644 (file)
@@ -293,6 +293,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 */