summaryrefslogtreecommitdiff
path: root/lib/libalpm/dload.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-12-02 22:15:02 -0600
committerDan McGee <dan@archlinux.org>2008-12-02 22:15:02 -0600
commit61c6552862345cb155903cd1566f1cef5c527a94 (patch)
treea9c85c46a4ccd5cd8c001689541706e9287e4c50 /lib/libalpm/dload.c
parent9394f229a0328228e810b7d4588b24643b42df6a (diff)
parenta1f7c83dbf3bce492163362d2896e3a4176be616 (diff)
downloadpacman-61c6552862345cb155903cd1566f1cef5c527a94.tar.xz
Merge branch 'maint'
Conflicts: lib/libalpm/dload.c
Diffstat (limited to 'lib/libalpm/dload.c')
-rw-r--r--lib/libalpm/dload.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index f197d060..9934f30a 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -112,12 +112,12 @@ static int download_internal(const char *url, const char *localpath,
FILE *dlf, *localf = NULL;
struct url_stat ust;
struct stat st;
- int chk_resume = 0;
- size_t dl_thisfile = 0;
+ int chk_resume = 0, ret = 0;
+ size_t dl_thisfile = 0, nread = 0;
char *tempfile, *destfile, *filename;
- int ret = 0;
struct sigaction new_action, old_action;
struct url *fileurl = url_for_string(url);
+ char buffer[PM_DLBUF_LEN];
if(!fileurl) {
return(-1);
@@ -208,9 +208,8 @@ static int download_internal(const char *url, const char *localpath,
handle->dlcb(filename, 0, ust.size);
}
- size_t nread = 0;
- char buffer[PM_DLBUF_LEN];
while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) {
+ size_t nwritten = 0;
if(ferror(dlf)) {
pm_errno = PM_ERR_LIBFETCH;
_alpm_log(PM_LOG_ERROR, _("error downloading '%s': %s\n"),
@@ -219,7 +218,6 @@ static int download_internal(const char *url, const char *localpath,
goto cleanup;
}
- size_t nwritten = 0;
while(nwritten < nread) {
nwritten += fwrite(buffer, 1, (nread - nwritten), localf);
if(ferror(localf)) {