From: Patrick Uiterwijk Date: Mon, 26 Sep 2016 12:45:25 +0000 (+0000) Subject: Make set_record act like a setter X-Git-Tag: upstream/0.10.0~4^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1a7d9b5e7ee493133daf608adaf80b10a87b915;p=services%2Fcreaterepo_c.git 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 --- 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); }