From: Kern Sibbald Date: Sat, 13 Feb 2010 11:34:08 +0000 (+0100) Subject: Tweak add error checks X-Git-Tag: Release-5.2.1~1761 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e64ff850c54af68fe2add67779c23dc31a3330ea;p=bacula%2Fbacula Tweak add error checks --- diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index a635861e41..5290b99e55 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -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 */ diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index c68e4cb3a9..a34fe4a933 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -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 */