summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/dload.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 57c21b8e..a06cb462 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -124,6 +124,10 @@ static int download_internal(const char *url, const char *localpath,
destfile = get_destfile(localpath, filename);
tempfile = get_tempfile(localpath, filename);
+ if(mtimeold) {
+ fileurl->last_modified = mtimeold;
+ }
+
/* pass the raw filename for passing to the callback function */
_alpm_log(PM_LOG_DEBUG, "using '%s' for download progress\n", filename);
@@ -157,7 +161,13 @@ static int download_internal(const char *url, const char *localpath,
sigaction(SIGPIPE, NULL, &old_action);
sigaction(SIGPIPE, &new_action, NULL);
- dlf = fetchXGet(fileurl, &ust, (handle->nopassiveftp ? "" : "p"));
+ dlf = fetchXGet(fileurl, &ust, (handle->nopassiveftp ? "i" : "pi"));
+
+ if(fetchLastErrCode == FETCH_UNCHANGED) {
+ _alpm_log(PM_LOG_DEBUG, "mtimes are identical, skipping %s\n", filename);
+ ret = 1;
+ goto cleanup;
+ }
if(fetchLastErrCode != 0 || dlf == NULL) {
const char *host = _("disk");
@@ -173,12 +183,6 @@ static int download_internal(const char *url, const char *localpath,
_alpm_log(PM_LOG_DEBUG, "connected to %s successfully\n", fileurl->host);
}
- if(ust.mtime && mtimeold && ust.mtime == mtimeold) {
- _alpm_log(PM_LOG_DEBUG, "mtimes are identical, skipping %s\n", filename);
- ret = 1;
- goto cleanup;
- }
-
if(ust.mtime && mtimenew) {
*mtimenew = ust.mtime;
}
@@ -210,14 +214,12 @@ static int download_internal(const char *url, const char *localpath,
while((nread = fetchIO_read(dlf, buffer, PM_DLBUF_LEN)) > 0) {
size_t nwritten = 0;
- while(nwritten < nread) {
- nwritten += fwrite(buffer, 1, (nread - nwritten), localf);
- if(ferror(localf)) {
- _alpm_log(PM_LOG_ERROR, _("error writing to file '%s': %s\n"),
- destfile, strerror(errno));
- ret = -1;
- goto cleanup;
- }
+ nwritten = fwrite(buffer, 1, nread, localf);
+ if((nwritten != nread) || ferror(localf)) {
+ _alpm_log(PM_LOG_ERROR, _("error writing to file '%s': %s\n"),
+ destfile, strerror(errno));
+ ret = -1;
+ goto cleanup;
}
dl_thisfile += nread;