From f1a7d9b5e7ee493133daf608adaf80b10a87b915 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Mon, 26 Sep 2016 12:45:25 +0000 Subject: [PATCH] Make set_record act like a setter This will make sure that when set_record is called, all existing records of the same type are removed. It makes no sense to have multiple records of the same type, and it actively breaks libhifs checksum validation. Signed-off-by: Patrick Uiterwijk --- src/repomd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/repomd.c b/src/repomd.c index fea2c7e..3e79ccf 100644 --- a/src/repomd.c +++ b/src/repomd.c @@ -682,6 +682,14 @@ cr_repomd_set_record(cr_Repomd *repomd, cr_RepomdRecord *record) { if (!repomd || !record) return; + + cr_RepomdRecord *delrec = NULL; + // Remove all existing record of the same type + while((delrec = cr_repomd_get_record(repomd, record->type)) != NULL) { + cr_repomd_detach_record(repomd, delrec); + cr_repomd_record_free(delrec); + } + repomd->records = g_slist_append(repomd->records, record); } -- 2.7.4