[pacman-dev] CVS update of pacman-lib (3 files)
Aaron Griffin
aaron at archlinux.org
Tue Mar 20 23:08:20 EDT 2007
Date: Tuesday, March 20, 2007 @ 23:08:20
Author: aaron
Path: /home/cvs-pacman/pacman-lib
Modified: lib/libalpm/server.c (1.26 -> 1.27)
lib/libalpm/sync.c (1.111 -> 1.112)
src/pacman/query.c (1.29 -> 1.30)
* 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(-)
Index: pacman-lib/lib/libalpm/server.c
diff -u pacman-lib/lib/libalpm/server.c:1.26 pacman-lib/lib/libalpm/server.c:1.27
--- pacman-lib/lib/libalpm/server.c:1.26 Mon Mar 12 19:26:47 2007
+++ pacman-lib/lib/libalpm/server.c Tue Mar 20 23:08:19 2007
@@ -29,6 +29,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
+#include <errno.h>
#include <download.h>
/* libalpm */
@@ -290,6 +291,9 @@
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 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);
Index: pacman-lib/lib/libalpm/sync.c
diff -u pacman-lib/lib/libalpm/sync.c:1.111 pacman-lib/lib/libalpm/sync.c:1.112
--- pacman-lib/lib/libalpm/sync.c:1.111 Mon Mar 19 22:36:21 2007
+++ pacman-lib/lib/libalpm/sync.c Tue Mar 20 23:08:19 2007
@@ -317,7 +317,7 @@
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"),
Index: pacman-lib/src/pacman/query.c
diff -u pacman-lib/src/pacman/query.c:1.29 pacman-lib/src/pacman/query.c:1.30
--- pacman-lib/src/pacman/query.c:1.29 Sun Mar 11 21:25:40 2007
+++ pacman-lib/src/pacman/query.c Tue Mar 20 23:08:20 2007
@@ -27,6 +27,7 @@
#include <string.h>
#include <sys/stat.h>
#include <libintl.h>
+#include <errno.h>
#include <alpm.h>
#include <alpm_list.h>
@@ -57,8 +58,18 @@
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;
}
More information about the pacman-dev
mailing list