From 5a8bbc99be0ec8ea264fca061276e9ec798bca5e Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 31 Oct 2006 06:41:42 +0000 Subject: Numerous changes: * Added 'ILoveCandy' support to all progress bars * Changed download callback with regards to libfetch libalpm changes * libfetch error output on failed sync * Misc others I may have forgot to name (check the diff, heh) --- src/pacman/sync.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/pacman/sync.c') diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 07cd3699..012a7604 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -37,6 +37,7 @@ #endif #include +#include /* fetchLastErrString */ /* pacman */ #include "util.h" #include "log.h" @@ -53,11 +54,14 @@ extern list_t *pmc_syncs; static int sync_cleancache(int level) { + long lroot, lcachedir; char *root, *cachedir; char dirpath[PATH_MAX]; - alpm_get_option(PM_OPT_ROOT, (long *)&root); - alpm_get_option(PM_OPT_CACHEDIR, (long *)&cachedir); + alpm_get_option(PM_OPT_ROOT, &lroot); + root = (void *)&lroot; + alpm_get_option(PM_OPT_CACHEDIR, &lcachedir); + cachedir = (void *)&lcachedir; snprintf(dirpath, PATH_MAX, "%s%s", root, cachedir); @@ -162,14 +166,15 @@ static int sync_synctree(int level, list_t *syncs) sync_t *sync = (sync_t *)i->data; ret = alpm_db_update((level < 2 ? 0 : 1), sync->db); - if(ret > 0) { + if(ret < 0) { if(pm_errno == PM_ERR_DB_SYNC) { - ERR(NL, _("failed to synchronize %s\n"), sync->treename); + /* use libfetch error */ + ERR(NL, _("failed to synchronize %s: %s\n"), sync->treename, fetchLastErrString); } else { ERR(NL, _("failed to update %s (%s)\n"), sync->treename, alpm_strerror(pm_errno)); } success--; - } else if(ret < 0) { + } else if(ret == 1) { MSG(NL, _(" %s is up to date\n"), sync->treename); } } @@ -350,7 +355,7 @@ int pacman_sync(list_t *targets) { int confirm = 0; int retval = 0; - list_t *i; + list_t *i = NULL; PM_LIST *packages, *data, *lp; if(pmc_syncs == NULL || !list_count(pmc_syncs)) { @@ -495,7 +500,7 @@ int pacman_sync(list_t *targets) /* targ not found in sync db, searching for providers... */ PM_LIST *k = NULL; PM_PKG *pkg; - char *pname; + char *pname = NULL; for(j = pmc_syncs; j && !k; j = j->next) { sync_t *sync = j->data; k = alpm_db_whatprovides(sync->db, targ); -- cgit v1.2.3