From 4e1e69c429661e10090b37c3c980f1cc6548ee86 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 13 Feb 2010 12:34:08 +0100 Subject: [PATCH] Tweak add error checks --- bacula/src/cats/sql_create.c | 1 + bacula/src/dird/dird.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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 */ -- 2.39.5