Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Jan 2011 14:41:58 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r217352 - user/nwhitehorn/bsdinstall/distfetch
Message-ID:  <201101131441.p0DEfw2P053727@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Thu Jan 13 14:41:58 2011
New Revision: 217352
URL: http://svn.freebsd.org/changeset/base/217352

Log:
  Provide better error reporting in distfetch.

Modified:
  user/nwhitehorn/bsdinstall/distfetch/distfetch.c

Modified: user/nwhitehorn/bsdinstall/distfetch/distfetch.c
==============================================================================
--- user/nwhitehorn/bsdinstall/distfetch/distfetch.c	Thu Jan 13 14:22:27 2011	(r217351)
+++ user/nwhitehorn/bsdinstall/distfetch/distfetch.c	Thu Jan 13 14:41:58 2011	(r217352)
@@ -11,7 +11,7 @@ main(void)
 {
 	char *diststring = strdup(getenv("DISTRIBUTIONS"));
 	char **urls;
-	int i, retval, ndists = 0;
+	int i, nfetched, ndists = 0;
 	for (i = 0; diststring[i] != 0; i++)
 		if (isspace(diststring[i]) && !isspace(diststring[i+1]))
 			ndists++;
@@ -25,14 +25,14 @@ main(void)
 	}
 
 	chdir(getenv("BSDINSTALL_DISTDIR"));
-	retval = fetch_files(ndists, urls);
+	nfetched = fetch_files(ndists, urls);
 
 	free(diststring);
 	for (i = 0; i < ndists; i++) 
 		free(urls[i]);
 	free(urls);
 
-	return (retval);
+	return ((nfetched == ndists) ? 0 : 1);
 }
 
 static int
@@ -47,6 +47,7 @@ fetch_files(int nfiles, char **urls)
 	uint8_t block[4096];
 	size_t chunk, fsize;
 	int i, progress, last_progress;
+	int nsuccess = 0; /* Number of files successfully downloaded */
 
 	progress = 0;
 	
@@ -131,8 +132,6 @@ fetch_files(int nfiles, char **urls)
 				    __DECONST(char **, items));
 		}
 
-		items[i*2 + 1] = "Done";
-
 		if (ustat.size > 0 && fsize < (size_t)ustat.size) {
 			if (fetchLastErrCode == 0) 
 				snprintf(errormsg, sizeof(errormsg),
@@ -145,6 +144,9 @@ fetch_files(int nfiles, char **urls)
 			items[i*2 + 1] = "Failed";
 			dialog_msgbox("Fetch Error", errormsg, 0, 0,
 				    TRUE);
+		} else {
+			items[i*2 + 1] = "Done";
+			nsuccess++;
 		}
 
 		fclose(fetch_out);
@@ -153,5 +155,5 @@ fetch_files(int nfiles, char **urls)
 	end_dialog();
 
 	free(items);
-	return (0);
+	return (nsuccess);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101131441.p0DEfw2P053727>