diff options
author | Dan McGee <dan@archlinux.org> | 2007-08-20 19:28:51 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-08-20 21:23:46 +0200 |
commit | 17d9122e01f5a675f4c7882e68ceae65aae7b5aa (patch) | |
tree | 4f9f9a5099073c57c8ff4472ad9f9cead0b76272 /lib/libalpm/package.c | |
parent | 942175feaa866c4e536a7da0f77ab54de98b6c07 (diff) | |
download | pacman-17d9122e01f5a675f4c7882e68ceae65aae7b5aa.tar.gz pacman-17d9122e01f5a675f4c7882e68ceae65aae7b5aa.tar.xz |
Fix for FS 6404 and functionalize some cachedir handling stuff
In order to best resolve bug 6404, move some cachedir handling stuff out of
sync.c and into util.c and create two new functions: filecache_find and
filecache_setup. sync.c was rewritten to use these, and alpm_fetch_pkgurl
now also uses these routines.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r-- | lib/libalpm/package.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index cb56bccf..e11d7476 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -101,10 +101,8 @@ int SYMEXPORT alpm_pkg_free(pmpkg_t *pkg) */ int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg) { - char path[PATH_MAX]; - struct stat buf; + char *fpath; char *md5sum = NULL; - alpm_list_t *i; int retval = 0; ALPM_LOG_FUNC; @@ -114,16 +112,9 @@ int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg) ASSERT(pkg->origin == PKG_FROM_CACHE, RET_ERR(PM_ERR_PKG_INVALID, -1)); ASSERT(pkg->origin_data.db != handle->db_local, RET_ERR(PM_ERR_PKG_INVALID, -1)); - /* Loop through the cache dirs until we find a matching file */ - for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) { - snprintf(path, PATH_MAX, "%s%s-%s" PKGEXT, (char*)alpm_list_getdata(i), - alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); - if(stat(path, &buf) == 0) { - break; - } - } + fpath = _alpm_filecache_find(alpm_pkg_get_filename(pkg)); + md5sum = alpm_get_md5sum(fpath); - md5sum = alpm_get_md5sum(path); if(md5sum == NULL) { _alpm_log(PM_LOG_ERROR, _("could not get md5sum for package %s-%s"), alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); @@ -141,6 +132,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg) } } + FREE(fpath); FREE(md5sum); return(retval); |