Imported Upstream version 0.6.13
[platform/upstream/libsolv.git] / ext / repo_zyppdb.c
index 19eabd9..5200c29 100644 (file)
@@ -23,6 +23,7 @@
 #include <assert.h>
 #include <dirent.h>
 #include <expat.h>
+#include <errno.h>
 
 #include "pool.h"
 #include "repo.h"
@@ -160,7 +161,6 @@ startElement(void *userData, const char *name, const char **atts)
        /* parse 'type' */
        const char *type = find_attr("type", atts);
        s = pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
-       repodata_extend(pd->data, s - pool->solvables);
        pd->handle = s - pool->solvables;
        if (type)
          repodata_set_str(pd->data, pd->handle, PRODUCT_TYPE, type);
@@ -289,6 +289,11 @@ add_zyppdb_product(struct parsedata *pd, FILE *fp)
       if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
        {
          pool_debug(pd->pool, SOLV_ERROR, "repo_zyppdb: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
+         if (pd->solvable)
+           {
+             repo_free_solvable(pd->repo, pd->solvable - pd->pool->solvables, 1);
+             pd->solvable = 0;
+           }
          return;
        }
       if (l == 0)
@@ -315,7 +320,7 @@ repo_add_zyppdb_products(Repo *repo, const char *dirpath, int flags)
   DIR *dir;
   FILE *fp;
   Repodata *data;
-  
+
   data = repo_add_repodata(repo, flags);
   memset(&pd, 0, sizeof(pd));
   pd.repo = repo;
@@ -344,7 +349,7 @@ repo_add_zyppdb_products(Repo *repo, const char *dirpath, int flags)
          fullpath = join2(&pd.jd, dirpath, "/", entry->d_name);
          if ((fp = fopen(fullpath, "r")) == 0)
            {
-             perror(fullpath);
+             pool_error(repo->pool, 0, "%s: %s", fullpath, strerror(errno));
              continue;
            }
          add_zyppdb_product(&pd, fp);