libsolv/0007-rpmmd-diskusage-prepend-a-to-the-dir-if-not-already-.patch
2016-03-08 13:12:00 +01:00

51 lines
1.5 KiB
Diff

From 5218114520e47f50bef59606d32d9434ee4b6f47 Mon Sep 17 00:00:00 2001
From: Michael Schroeder <mls@suse.de>
Date: Thu, 3 Mar 2016 12:59:18 +0100
Subject: [PATCH 6/9] rpmmd diskusage: prepend a '/' to the dir if not already
there
Makes the code consistent with repo_susetags.
---
ext/repo_rpmmd.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/ext/repo_rpmmd.c b/ext/repo_rpmmd.c
index 5ef5c25..78264cc 100644
--- a/ext/repo_rpmmd.c
+++ b/ext/repo_rpmmd.c
@@ -1014,15 +1014,24 @@ startElement(void *userData, const char *name, const char **atts)
{
long filesz = 0, filenum = 0;
Id dirid;
- if ((str = find_attr("name", atts)) != 0)
- dirid = repodata_str2dir(pd->data, str, 1);
- else
- {
+ if ((str = find_attr("name", atts)) == 0)
+ {
pd->ret = pool_error(pool, -1, "<dir .../> tag without 'name' attribute");
break;
- }
- if (!dirid)
- dirid = repodata_str2dir(pd->data, "/", 1);
+ }
+ if (*str != '/')
+ {
+ int l = strlen(str) + 2;
+ if (l > pd->acontent)
+ {
+ pd->content = solv_realloc(pd->content, l + 256);
+ pd->acontent = l + 256;
+ }
+ *pd->content = '/';
+ strcpy(pd->content + 1, str);
+ str = pd->content;
+ }
+ dirid = repodata_str2dir(pd->data, str, 1);
if ((str = find_attr("size", atts)) != 0)
filesz = strtol(str, 0, 0);
if ((str = find_attr("count", atts)) != 0)
--
2.5.0