|
|
a3a8ff |
From f1a7d9b5e7ee493133daf608adaf80b10a87b915 Mon Sep 17 00:00:00 2001
|
|
|
a3a8ff |
From: Patrick Uiterwijk <puiterwijk@redhat.com>
|
|
|
a3a8ff |
Date: Mon, 26 Sep 2016 12:45:25 +0000
|
|
|
a3a8ff |
Subject: [PATCH 1/2] Make set_record act like a setter
|
|
|
a3a8ff |
|
|
|
a3a8ff |
This will make sure that when set_record is called, all existing
|
|
|
a3a8ff |
records of the same type are removed.
|
|
|
a3a8ff |
It makes no sense to have multiple records of the same type,
|
|
|
a3a8ff |
and it actively breaks libhifs checksum validation.
|
|
|
a3a8ff |
|
|
|
a3a8ff |
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
|
|
|
a3a8ff |
---
|
|
|
a3a8ff |
src/repomd.c | 8 ++++++++
|
|
|
a3a8ff |
1 file changed, 8 insertions(+)
|
|
|
a3a8ff |
|
|
|
a3a8ff |
diff --git a/src/repomd.c b/src/repomd.c
|
|
|
a3a8ff |
index fea2c7e..3e79ccf 100644
|
|
|
a3a8ff |
--- a/src/repomd.c
|
|
|
a3a8ff |
+++ b/src/repomd.c
|
|
|
a3a8ff |
@@ -682,6 +682,14 @@ cr_repomd_set_record(cr_Repomd *repomd,
|
|
|
a3a8ff |
cr_RepomdRecord *record)
|
|
|
a3a8ff |
{
|
|
|
a3a8ff |
if (!repomd || !record) return;
|
|
|
a3a8ff |
+
|
|
|
a3a8ff |
+ cr_RepomdRecord *delrec = NULL;
|
|
|
a3a8ff |
+ // Remove all existing record of the same type
|
|
|
a3a8ff |
+ while((delrec = cr_repomd_get_record(repomd, record->type)) != NULL) {
|
|
|
a3a8ff |
+ cr_repomd_detach_record(repomd, delrec);
|
|
|
a3a8ff |
+ cr_repomd_record_free(delrec);
|
|
|
a3a8ff |
+ }
|
|
|
a3a8ff |
+
|
|
|
a3a8ff |
repomd->records = g_slist_append(repomd->records, record);
|
|
|
a3a8ff |
}
|
|
|
a3a8ff |
|
|
|
a3a8ff |
|
|
|
a3a8ff |
From 5e44d23842d68e31e92498edeb6aba2e72a63abd Mon Sep 17 00:00:00 2001
|
|
|
a3a8ff |
From: Patrick Uiterwijk <puiterwijk@redhat.com>
|
|
|
a3a8ff |
Date: Mon, 26 Sep 2016 12:48:31 +0000
|
|
|
a3a8ff |
Subject: [PATCH 2/2] Add test to make sure that set_record overrides the
|
|
|
a3a8ff |
current record
|
|
|
a3a8ff |
|
|
|
a3a8ff |
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
|
|
|
a3a8ff |
---
|
|
|
a3a8ff |
tests/python/tests/test_repomd.py | 4 ++++
|
|
|
a3a8ff |
1 file changed, 4 insertions(+)
|
|
|
a3a8ff |
|
|
|
a3a8ff |
diff --git a/tests/python/tests/test_repomd.py b/tests/python/tests/test_repomd.py
|
|
|
a3a8ff |
index 283dedc..6b6b3ad 100644
|
|
|
a3a8ff |
--- a/tests/python/tests/test_repomd.py
|
|
|
a3a8ff |
+++ b/tests/python/tests/test_repomd.py
|
|
|
a3a8ff |
@@ -99,6 +99,10 @@ def test_repomd(self):
|
|
|
a3a8ff |
|
|
|
a3a8ff |
self.assertEqual(len(md.records), 1)
|
|
|
a3a8ff |
|
|
|
a3a8ff |
+ md.set_record(rec)
|
|
|
a3a8ff |
+
|
|
|
a3a8ff |
+ self.assertEqual(len(md.records), 1)
|
|
|
a3a8ff |
+
|
|
|
a3a8ff |
md.repoid = None
|
|
|
a3a8ff |
md.contenthash = None
|
|
|
a3a8ff |
|