aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2003-09-29 12:51:23 +0000
committerJason Woodward2003-09-29 12:51:23 +0000
commitabed1162d037aa21b67e6b686adc1bea6776b095 (patch)
treeca87fa2ef1ead5cb83841504d0e9694519a8bf93
parentc5baa75a77716046148c77043be5e7b488251b45 (diff)
downloadslapt-get-abed1162d037aa21b67e6b686adc1bea6776b095.tar.gz
additional error checking, more graceful handling of d/l errors
-rw-r--r--ChangeLog3
-rw-r--r--src/curl.c29
-rw-r--r--src/curl.h2
3 files changed, 22 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index d5eae5c..ef40c09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,10 @@
-0.9.4 Sep 28, 2003
+0.9.4 Sep 29, 2003
* downloads CHECKSUMS.md5 from mirror
* md5 sum's each package after downloading (from CHECKSUMS.md5 data)
utilizing openssl/evp.h
* pre-download check... won't download twice if md5sum is good
+ * error checking updates
0.9.3 Sep 24, 2003
* default make target doesn't build slack pkg
diff --git a/src/curl.c b/src/curl.c
index 518b042..449b714 100644
--- a/src/curl.c
+++ b/src/curl.c
@@ -18,10 +18,11 @@
#include <main.h>
-void download_data(FILE *fh,const char *url){
+int download_data(FILE *fh,const char *url){
CURL *ch = NULL;
CURLcode response;
char curl_err_buff[1024];
+ int return_code = 1;
#if DEBUG == 1
printf("Fetching url:[%s]\n",url);
@@ -37,9 +38,12 @@ void download_data(FILE *fh,const char *url){
if( (response = curl_easy_perform(ch)) != 0 ){
fprintf(stderr,"failed to download: %s\n",curl_err_buff);
+ return_code = -1;
}
/* curl_easy_cleanup(ch); */
curl_free(ch);
+
+ return return_code;
}
FILE *download_pkg_list(const rc_config *global_config){
@@ -64,10 +68,11 @@ FILE *download_pkg_list(const rc_config *global_config){
strncpy(url,global_config->mirror_url,strlen(global_config->mirror_url) );
strncat(url,PKG_LIST,strlen(PKG_LIST) );
- download_data(fh,url);
+ if( download_data(fh,url) == 1 ){
#if USE_CURL_PROGRESS == 0
- printf("Done\n");
+ printf("Done\n");
#endif
+ }
free(url);
rewind(fh); /* make sure we are back at the front of the file */
@@ -97,10 +102,11 @@ FILE *download_patches_list(const rc_config *global_config){
strncpy(url,global_config->mirror_url,strlen(global_config->mirror_url) );
strncat(url,PATCHDIR,strlen(PATCHDIR) );
strncat(url,PATCHES_LIST,strlen(PATCHES_LIST) );
- download_data(fh,url);
+ if( download_data(fh,url) == 1 ){
#if USE_CURL_PROGRESS == 0
- printf("Done\n");
+ printf("Done\n");
#endif
+ }
free(url);
rewind(fh); /* make sure we are back at the front of the file */
@@ -129,10 +135,11 @@ FILE *download_checksum_list(const rc_config *global_config){
strncpy(url,global_config->mirror_url,strlen(global_config->mirror_url) );
strncat(url,CHECKSUM_FILE,strlen(CHECKSUM_FILE) );
- download_data(fh,url);
+ if( download_data(fh,url) == 1 ){
#if USE_CURL_PROGRESS == 0
- printf("Done\n");
+ printf("Done\n");
#endif
+ }
free(url);
rewind(fh); /* make sure we are back at the front of the file */
@@ -202,11 +209,13 @@ char *download_pkg(const rc_config *global_config,pkg_info_t *pkg){
#endif
fh = open_file(file_name,"wb");
- download_data(fh,url);
-
+ if( download_data(fh,url) == 1 ){
#if USE_CURL_PROGRESS == 0
- printf("Done\n");
+ printf("Done\n");
#endif
+ }else{
+ return file_name;
+ }
fclose(fh);
diff --git a/src/curl.h b/src/curl.h
index 1a986f9..c809cfb 100644
--- a/src/curl.h
+++ b/src/curl.h
@@ -19,7 +19,7 @@
#define USE_CURL_PROGRESS 0
/* FUNCTION DEFINITIONS */
-void download_data(FILE *,const char *);
+int download_data(FILE *,const char *);
FILE *download_pkg_list(const rc_config *);
FILE *download_file_list(const rc_config *);
FILE *download_patches_list(const rc_config *);