diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index c6c50a4..8dd93b0 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -295,6 +295,8 @@ alpm_list_t SYMEXPORT *alpm_find_group_pkgs(alpm_list_t *dbs, /** Compute the size of the files that will be downloaded to install a * package. * @param newpkg the new package to upgrade to + * @return 0 on success, 1 if we have a partial file, 2 if we are + * downloading deltas, -1 on failure */ static int compute_download_size(alpm_pkg_t *newpkg) { @@ -310,6 +312,12 @@ static int compute_download_size(alpm_pkg_t *newpkg) return 0; } + /* cleanup from any prior calls to this function */ + alpm_list_free(newpkg->delta_path); + newpkg->delta_path = NULL; + newpkg->download_size = 0; + newpkg->infolevel &= !INFRQ_DSIZE; + ASSERT(newpkg->filename != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1)); fname = newpkg->filename; fpath = _alpm_filecache_find(handle, fname); @@ -343,6 +351,8 @@ static int compute_download_size(alpm_pkg_t *newpkg) if(newpkg->delta_path && (dltsize < newpkg->size * handle->deltaratio)) { _alpm_log(handle, ALPM_LOG_DEBUG, "using delta size\n"); size = dltsize; + /* tell the caller that we are downloading deltas */ + ret = 2; } else { _alpm_log(handle, ALPM_LOG_DEBUG, "using package size\n"); size = newpkg->size;