From aa36cebd40b12453ab4c2570cf7de68b1a3bf631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= Date: Thu, 23 May 2019 14:08:37 +0200 Subject: [PATCH] Prevent exiting with 0 if errors occur while finalizing repodata. --- src/createrepo_c.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/createrepo_c.c b/src/createrepo_c.c index 2326cb51..db242be3 100644 --- a/src/createrepo_c.c +++ b/src/createrepo_c.c @@ -1110,9 +1110,16 @@ main(int argc, char **argv) cr_xml_dump_cleanup(); - cr_xmlfile_close(pri_cr_file, NULL); - cr_xmlfile_close(fil_cr_file, NULL); - cr_xmlfile_close(oth_cr_file, NULL); + cr_xmlfile_close(pri_cr_file, &tmp_err); + if (!tmp_err) + cr_xmlfile_close(fil_cr_file, &tmp_err); + if (!tmp_err) + cr_xmlfile_close(oth_cr_file, &tmp_err); + if (tmp_err) { + g_critical("Error while closing xml files: %s", tmp_err->message); + g_clear_error(&tmp_err); + exit(EXIT_FAILURE); + } cr_xmlfile_close(pri_cr_zck, &tmp_err); if (tmp_err) { @@ -1321,13 +1328,27 @@ main(int argc, char **argv) gchar *oth_db_name = g_strconcat(tmp_out_repo, "/other.sqlite", sqlite_compression_suffix, NULL); - cr_db_dbinfo_update(pri_db, pri_xml_rec->checksum, NULL); - cr_db_dbinfo_update(fil_db, fil_xml_rec->checksum, NULL); - cr_db_dbinfo_update(oth_db, oth_xml_rec->checksum, NULL); + cr_db_dbinfo_update(pri_db, pri_xml_rec->checksum, &tmp_err); + if (!tmp_err) + cr_db_dbinfo_update(fil_db, fil_xml_rec->checksum, &tmp_err); + if (!tmp_err) + cr_db_dbinfo_update(oth_db, oth_xml_rec->checksum, &tmp_err); + if (tmp_err) { + g_critical("Error updating dbinfo: %s", tmp_err->message); + g_clear_error(&tmp_err); + exit(EXIT_FAILURE); + } - cr_db_close(pri_db, NULL); - cr_db_close(fil_db, NULL); - cr_db_close(oth_db, NULL); + cr_db_close(pri_db, &tmp_err); + if (!tmp_err) + cr_db_close(fil_db, &tmp_err); + if (!tmp_err) + cr_db_close(oth_db, &tmp_err); + if (tmp_err) { + g_critical("Error while closing db: %s", tmp_err->message); + g_clear_error(&tmp_err); + exit(EXIT_FAILURE); + } // Compress dbs