From: Michal Rakowski Date: Tue, 1 Dec 2020 13:57:59 +0000 (+0100) Subject: Fix bscan's flushing file records in batch X-Git-Tag: Release-11.3.2~816 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41fc196dcb0c73c2c83b5db7bdbd89f67ef39392;p=thirdparty%2Fbacula.git Fix bscan's flushing file records in batch --- diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 3341a71ef..615cbf552 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -756,7 +756,11 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) edit_uint64_with_commas(rec->Addr, ed2), edit_uint64_with_commas(mr.VolBytes, ed3)); } - create_file_attributes_record(mjcr, attr, rec); + if (!create_file_attributes_record(mjcr, attr, rec)) { + Jmsg2(mjcr, M_ERROR, 0, _("Failed to insert record for file: %s. err: %s\n"), + attr->fname, db_strerror(db)); + break; + } break; case STREAM_RESTORE_OBJECT: @@ -1007,9 +1011,12 @@ static void bscan_free_jcr(JCR *jcr) /* Close thej jcr's db connections */ if (jcr->db_batch) { + if (!db_write_batch_file_records(bjcr)) { /* used by bulk batch file insert */ + Jmsg0(jcr, M_ERROR, 0, _("Failed to flush file records!\n")); + } + db_close_database(jcr, jcr->db_batch); jcr->db_batch = NULL; - jcr->batch_started = false; } if (jcr->db) { db_close_database(jcr, jcr->db);