aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-04-18 17:38:56 +0000
committerMike Frysinger <vapier@gentoo.org>2007-04-18 17:38:56 +0000
commit22db950d180f05f04623f6197c9dcdac7f3eefd8 (patch)
treec84b697951ed0241b9b21f7a2f393ce91f358710
parentimplement xzalloc() for "xmalloc() && memset()" (diff)
downloadportage-utils-22db950d180f05f04623f6197c9dcdac7f3eefd8.tar.gz
portage-utils-22db950d180f05f04623f6197c9dcdac7f3eefd8.tar.bz2
portage-utils-22db950d180f05f04623f6197c9dcdac7f3eefd8.zip
continue gracefully if cache is out of sync with portdir
-rw-r--r--qcache.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/qcache.c b/qcache.c
index 0c4b2386..61b360ad 100644
--- a/qcache.c
+++ b/qcache.c
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2006 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qcache.c,v 1.24 2007/04/18 17:31:19 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qcache.c,v 1.25 2007/04/18 17:38:56 vapier Exp $
*
* Copyright 2006 Thomas A. Cort - <tcort@gentoo.org>
*/
@@ -48,7 +48,7 @@ static const char *qcache_opts_help[] = {
COMMON_OPTS_HELP
};
-static const char qcache_rcsid[] = "$Id: qcache.c,v 1.24 2007/04/18 17:31:19 vapier Exp $";
+static const char qcache_rcsid[] = "$Id: qcache.c,v 1.25 2007/04/18 17:38:56 vapier Exp $";
#define qcache_usage(ret) usage(ret, QCACHE_FLAGS, qcache_long_opts, qcache_opts_help, lookup_applet_idx("qcache"))
/********************************************************************/
@@ -344,8 +344,7 @@ portage_cache *qcache_read_cache_file(const char *filename)
}
len = sizeof(*ret) + s.st_size + 1;
- ret = xmalloc(len);
- memset(ret, 0x00, len);
+ ret = xzalloc(len);
while ((fgets(buf, sizeof(buf), f)) != NULL) {
if ((ptr = strrchr(buf, '\n')) != NULL)
@@ -588,17 +587,19 @@ int qcache_traverse(void (*func)(qcache_data*))
data.cur = k + 1;
data.num = num_ebuild;
data.cache_data = qcache_read_cache_file(cachepath);
- if (data.cache_data == NULL)
- err("unable to read the cache data at '%s'", cachepath);
- /* is this the last ebuild? */
- if (i+1 == num_cat && j+1 == num_pkg && k+1 == num_ebuild)
- qcache_last = 1;
+ if (data.cache_data != NULL) {
+ /* is this the last ebuild? */
+ if (i+1 == num_cat && j+1 == num_pkg && k+1 == num_ebuild)
+ qcache_last = 1;
- if (!qcache_skip)
- func(&data);
+ if (!qcache_skip)
+ func(&data);
+
+ qcache_free_data(data.cache_data);
+ } else
+ warn("unable to read cache '%s'\n\tperhaps you need to `emerge --metadata` ?", cachepath);
- qcache_free_data(data.cache_data);
free(ebuilds[k]);
free(cachepath);
}