Date: Saturday, February 10, 2007 @ 04:36:36 Author: aaron Path: /home/cvs-pacman/pacman-lib/lib/libalpm Modified: add.c (1.111 -> 1.112) alpm.c (1.115 -> 1.116) server.c (1.20 -> 1.21) * 'add' percentages now cap at 100% (see the comment) * downloaded packages now pass ONLY the package name to the callback ----------+ add.c | 16 +++++++++++++--- alpm.c | 9 +++++---- server.c | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 9 deletions(-) Index: pacman-lib/lib/libalpm/add.c diff -u pacman-lib/lib/libalpm/add.c:1.111 pacman-lib/lib/libalpm/add.c:1.112 --- pacman-lib/lib/libalpm/add.c:1.111 Fri Feb 9 16:08:10 2007 +++ pacman-lib/lib/libalpm/add.c Sat Feb 10 04:36:36 2007 @@ -496,10 +496,20 @@ char pathname[PATH_MAX]; struct stat buf; - STRNCPY(pathname, archive_entry_pathname (entry), PATH_MAX); + STRNCPY(pathname, archive_entry_pathname(entry), PATH_MAX); - if (info->size != 0) - percent = (double)archive_position_uncompressed(archive) / info->size; + if (info->size != 0) { + /* There's a problem here. These sizes don't match up. info->size is + * the COMPRESSED size, and info->isize is uncompressed. It appears, + * however, that these are the only two sizes available. It appears + * to be close enough, BUT easilly goes over 100%, so we'll stall + * there for now */ + percent = (double)archive_position_uncompressed(archive) / info->size; + if(percent >= 1.0) { + percent = 1.0; + } + } + if (needdisp == 0) { PROGRESS(trans, cb_state, what, (int)(percent * 100), alpm_list_count(trans->packages), (alpm_list_count(trans->packages) - alpm_list_count(targ) +1)); } Index: pacman-lib/lib/libalpm/alpm.c diff -u pacman-lib/lib/libalpm/alpm.c:1.115 pacman-lib/lib/libalpm/alpm.c:1.116 --- pacman-lib/lib/libalpm/alpm.c:1.115 Fri Feb 9 16:54:57 2007 +++ pacman-lib/lib/libalpm/alpm.c Sat Feb 10 04:36:36 2007 @@ -593,14 +593,15 @@ arch = _supported_archs[i]; /* whee, case insensitive compare */ - while(*arch && *cmp && tolower(*arch++) == tolower(*cmp++)) ; - if(*arch || *cmp) continue; + if(*arch || *cmp) { + continue; + } - return p; + return(p); } } - return NULL; + return(NULL); } /** @} */ Index: pacman-lib/lib/libalpm/server.c diff -u pacman-lib/lib/libalpm/server.c:1.20 pacman-lib/lib/libalpm/server.c:1.21 --- pacman-lib/lib/libalpm/server.c:1.20 Fri Feb 9 05:10:49 2007 +++ pacman-lib/lib/libalpm/server.c Sat Feb 10 04:36:36 2007 @@ -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 @@ 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 @@ } /* 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 @@ 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);