From 941c23025c886b820af8a17959bdf6dc4c2c0c9a Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 21 Mar 2007 03:08:19 +0000 Subject: * Fix asking the user to upgrade when using -Sp * More significant error messages when -Qo fails * Potential fix for reported error that pacman indicates corrupt packages when space is full on the cache dir --- lib/libalpm/server.c | 27 ++++++++++++++++++++++++++- lib/libalpm/sync.c | 2 +- src/pacman/query.c | 15 +++++++++++++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/lib/libalpm/server.c b/lib/libalpm/server.c index 80b264a2..27038946 100644 --- a/lib/libalpm/server.c +++ b/lib/libalpm/server.c @@ -29,6 +29,7 @@ #include #include #include +#include #include /* libalpm */ @@ -290,6 +291,9 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, localf = fopen(output, "w"); if(localf == NULL) { /* still null? */ _alpm_log(PM_LOG_ERROR, _("cannot write to file '%s'"), output); + if(dlf != NULL) { + fclose(dlf); + } return -1; } } @@ -300,8 +304,29 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, int nread = 0; char buffer[PM_DLBUF_LEN]; while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) { + if(ferror(dlf)) { + _alpm_log(PM_LOG_ERROR, _("error downloading '%s': %s"), + fn, downloadLastErrString); + fclose(localf); + fclose(dlf); + return(-1); + } + int nwritten = 0; - while((nwritten += fwrite(buffer, 1, (nread - nwritten), localf)) < nread) ; + while(nwritten < nread) { + nwritten += fwrite(buffer, 1, (nread - nwritten), localf); + if(ferror(localf)) { + _alpm_log(PM_LOG_ERROR, _("error writing to file '%s': %s"), + realfile, strerror(errno)); + fclose(localf); + fclose(dlf); + return(-1); + } + } + + if(nwritten != nread) { + + } dltotal_bytes += nread; if(handle->dlcb) handle->dlcb(pkgname, dltotal_bytes, ust.size); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index edc82a1b..1de78f75 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -317,7 +317,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy if(!resp) { return(0); } - } else { + } else if(!(trans->flags & PM_TRANS_FLAG_PRINTURIS)) { QUESTION(trans, PM_TRANS_CONV_LOCAL_UPTODATE, local, NULL, NULL, &resp); if(!resp) { _alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- skipping"), diff --git a/src/pacman/query.c b/src/pacman/query.c index 76cbc7fc..e7e9cf92 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -57,8 +58,18 @@ static void query_fileowner(pmdb_t *db, char *filename) return; } - if(stat(filename, &buf) == -1 || S_ISDIR(buf.st_mode) || realpath(filename, rpath) == NULL) { - /* fail silently if we're a directory */ + if(stat(filename, &buf) == -1) { + ERR(NL, _("failed to read file '%s': %s"), filename, strerror(errno)); + return; + } + + if(S_ISDIR(buf.st_mode)) { + ERR(NL, _("can not determine ownership of a directory")); + return; + } + + if(realpath(filename, rpath) == NULL) { + ERR(NL, _("cannot determine real path for '%s': %s"), filename, strerror(errno)); return; } -- cgit v1.2.3-70-g09d2