diff options
author | Dan McGee <dan@archlinux.org> | 2009-09-30 04:08:06 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2009-09-30 04:08:06 +0200 |
commit | 8e7652f1afd7ba5198f3aa10a94c50bb67f7a407 (patch) | |
tree | fb125716750985f491070796bd1a51211a0fe89b /lib | |
parent | 2071286770b3dbe531423aa3e8517dac68f04154 (diff) | |
parent | 20392c0a025d01128eb78c6656db7c15b3fbcd89 (diff) | |
download | pacman-8e7652f1afd7ba5198f3aa10a94c50bb67f7a407.tar.gz pacman-8e7652f1afd7ba5198f3aa10a94c50bb67f7a407.tar.xz |
Merge branch 'maint'
Conflicts:
lib/libalpm/dload.c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/dload.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index f8fb09fe..8b3226bd 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -76,6 +76,15 @@ static char *get_tempfile(const char *path, const char *filename) { return(tempfile); } +static const char *gethost(struct url *fileurl) +{ + const char *host = _("disk"); + if(strcmp(SCHEME_FILE, fileurl->scheme) != 0) { + host = fileurl->host; + } + return(host); +} + static int download_internal(const char *url, const char *localpath, time_t mtimeold, time_t *mtimenew) { fetchIO *dlf = NULL; @@ -83,7 +92,8 @@ static int download_internal(const char *url, const char *localpath, struct url_stat ust; struct stat st; int chk_resume = 0, ret = 0; - size_t dl_thisfile = 0, nread = 0; + size_t dl_thisfile = 0; + ssize_t nread = 0; char *tempfile, *destfile, *filename; struct sigaction new_action, old_action; struct url *fileurl; @@ -149,13 +159,9 @@ static int download_internal(const char *url, const char *localpath, } if(fetchLastErrCode != 0 || dlf == NULL) { - const char *host = _("disk"); - if(strcmp(SCHEME_FILE, fileurl->scheme) != 0) { - host = fileurl->host; - } pm_errno = PM_ERR_LIBFETCH; _alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"), - filename, host, fetchLastErrString); + filename, gethost(fileurl), fetchLastErrString); ret = -1; goto cleanup; } else { @@ -208,8 +214,17 @@ static int download_internal(const char *url, const char *localpath, } /* did the transfer complete normally? */ + if (nread == -1) { + /* not PM_ERR_LIBFETCH here because libfetch error string might be empty */ + pm_errno = PM_ERR_RETRIEVE; + _alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s\n"), + filename, gethost(fileurl)); + ret = -1; + goto cleanup; + } + if (ust.size != -1 && dl_thisfile < ust.size) { - pm_errno = PM_ERR_LIBFETCH; + pm_errno = PM_ERR_RETRIEVE; _alpm_log(PM_LOG_ERROR, _("%s appears to be truncated: %jd/%jd bytes\n"), filename, (intmax_t)dl_thisfile, (intmax_t)ust.size); ret = -1; |