summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libalpm/dload.c10
-rw-r--r--lib/libalpm/util.c5
-rw-r--r--src/pacman/upgrade.c2
3 files changed, 12 insertions, 5 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:
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 82387b2f..458f750a 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -608,19 +608,20 @@ char *_alpm_filecache_find(const char* filename)
char path[PATH_MAX];
char *retpath;
alpm_list_t *i;
+ struct stat buf;
/* Loop through the cache dirs until we find a matching file */
for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
snprintf(path, PATH_MAX, "%s%s", (char*)alpm_list_getdata(i),
filename);
- if(access(path, R_OK) == 0) {
+ if(stat(path, &buf) == 0 && S_ISREG(buf.st_mode)) {
retpath = strdup(path);
_alpm_log(PM_LOG_DEBUG, "found cached pkg: %s\n", retpath);
return(retpath);
}
}
/* package wasn't found in any cachedir */
- return(NULL);
+ RET_ERR(PM_ERR_PKG_NOT_FOUND, NULL);
}
/** Check the alpm cachedirs for existance and find a writable one.
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index 595e4aab..8cd29da0 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -55,6 +55,8 @@ int pacman_upgrade(alpm_list_t *targets)
if(strstr(i->data, "://")) {
char *str = alpm_fetch_pkgurl(i->data);
if(str == NULL) {
+ pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n",
+ (char *)i->data, alpm_strerrorlast());
return(1);
} else {
free(i->data);