summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/dload.c
diff options
context:
space:
mode:
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)) {