Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
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, 7 insertions, 3 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index cb6d000c..15d75556 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -128,13 +128,13 @@ static int download_internal(const char *url, const char *localpath,
destfile = get_destfile(localpath, filename);
tempfile = get_tempfile(localpath, filename);
- if(stat(tempfile, &st) == 0 && st.st_size > 0) {
+ if(stat(tempfile, &st) == 0 && S_ISREG(st.st_mode) && st.st_size > 0) {
_alpm_log(PM_LOG_DEBUG, "tempfile found, attempting continuation\n");
local_time = fileurl->last_modified = st.st_mtime;
local_size = fileurl->offset = (off_t)st.st_size;
dl_thisfile = st.st_size;
localf = fopen(tempfile, "ab");
- } else if(!force && stat(destfile, &st) == 0 && st.st_size > 0) {
+ } else if(!force && stat(destfile, &st) == 0 && S_ISREG(st.st_mode) && st.st_size > 0) {
_alpm_log(PM_LOG_DEBUG, "destfile found, using mtime only\n");
local_time = fileurl->last_modified = st.st_mtime;
local_size = /* no fu->off here */ (off_t)st.st_size;
@@ -296,7 +296,11 @@ static int download_internal(const char *url, const char *localpath,
tv[1].tv_sec = ust.mtime;
utimes(tempfile, tv);
}
- rename(tempfile, destfile);
+ if(rename(tempfile, destfile)) {
+ _alpm_log(PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
+ tempfile, destfile, strerror(errno));
+ ret = -1;
+ }
ret = 0;
cleanup: