From 5cbb203417f6828c45da0b7ad2268ba832c1d84d Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Tue, 9 Apr 2019 11:13:17 +0200 Subject: [PATCH] Allow to lookup a single id with repodata_lookup_idarray I don't see any harm in allowing this and it makes dealing with things like SOLVABLE_LICENSE easier which can be either an id (the old way) or an id array (the new way). --- src/repodata.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/repodata.c b/src/repodata.c index ad5aaea3..54d5bb23 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -791,14 +791,28 @@ repodata_lookup_idarray(Repodata *data, Id solvid, Id keyname, Queue *q) queue_empty(q); dp = find_key_data(data, solvid, keyname, &key); - if (!dp || key->type != REPOKEY_TYPE_IDARRAY) + if (!dp) return 0; - for (;;) + switch (key->type) { - dp = data_read_ideof(dp, &id, &eof); + case REPOKEY_TYPE_CONSTANTID: + queue_push(q, key->size); + break; + case REPOKEY_TYPE_ID: + dp = data_read_id(dp, &id); queue_push(q, id); - if (eof) - break; + break; + case REPOKEY_TYPE_IDARRAY: + for (;;) + { + dp = data_read_ideof(dp, &id, &eof); + queue_push(q, id); + if (eof) + break; + } + break; + default: + return 0; } return 1; } -- 2.47.2