diff options
author | Aaron Griffin <aaron@archlinux.org> | 2007-02-10 09:36:36 +0000 |
---|---|---|
committer | Aaron Griffin <aaron@archlinux.org> | 2007-02-10 09:36:36 +0000 |
commit | c55ea22c584596897be792fb7a788f04a363b5a8 (patch) | |
tree | 260717c7e942a81f62a5fa88e4be80f0f055eb3b /lib/libalpm/server.c | |
parent | a382d33d45d5e6c2a8ccca8fc946555f6123416f (diff) | |
download | pacman-c55ea22c584596897be792fb7a788f04a363b5a8.tar.xz |
* 'add' percentages now cap at 100% (see the comment)
* downloaded packages now pass ONLY the package name to the callback
Diffstat (limited to 'lib/libalpm/server.c')
-rw-r--r-- | lib/libalpm/server.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/libalpm/server.c b/lib/libalpm/server.c index e9713ce3..51f389d9 100644 --- a/lib/libalpm/server.c +++ b/lib/libalpm/server.c @@ -37,6 +37,7 @@ #include "util.h" #include "handle.h" #include "log.h" +#include "package.h" pmserver_t *_alpm_server_new(const char *url) { @@ -180,12 +181,22 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, char realfile[PATH_MAX]; char output[PATH_MAX]; char *fn = (char *)lp->data; + char pkgname[PKG_NAME_LEN]; + char *p; fileurl = url_for_file(server, fn); if(!fileurl) { return(-1); } + /* Try to get JUST the name of the package from the filename */ + p = alpm_pkg_name_hasarch(fn); /* TODO remove this later */ + _alpm_pkg_splitname(fn, pkgname, NULL, (p != NULL)); + if(!strlen(pkgname)) { + /* just use the raw filename if we can't find crap */ + STRNCPY(pkgname, fn, PKG_NAME_LEN); + } + snprintf(realfile, PATH_MAX, "%s/%s", localpath, fn); snprintf(output, PATH_MAX, "%s/%s.part", localpath, fn); @@ -278,7 +289,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, } /* Progress 0 - initialize */ - if(handle->dlcb) handle->dlcb(fn, 0, ust.size); + if(handle->dlcb) handle->dlcb(pkgname, 0, ust.size); int nread = 0; char buffer[PM_DLBUF_LEN]; @@ -287,7 +298,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, while((nwritten += fwrite(buffer, 1, (nread - nwritten), localf)) < nread) ; dltotal_bytes += nread; - if(handle->dlcb) handle->dlcb(fn, dltotal_bytes, ust.size); + if(handle->dlcb) handle->dlcb(pkgname, dltotal_bytes, ust.size); } fclose(localf); |