Only download yum files if they're not there.
1.1 --- a/main.c Mon Nov 05 19:06:52 2007 -0500
1.2 +++ b/main.c Mon Nov 05 21:55:31 2007 -0500
1.3 @@ -2,6 +2,8 @@
1.4 #include <stddef.h>
1.5 #include <stdio.h>
1.6 #include <string.h>
1.7 +#include <sys/types.h>
1.8 +#include <sys/stat.h>
1.9 #include <unistd.h>
1.10
1.11 #include <curl/curl.h>
1.12 @@ -149,23 +151,30 @@
1.13 CURL *curl;
1.14 CURLcode res;
1.15 FILE *fp;
1.16 + struct stat buf;
1.17
1.18 curl = curl_easy_init();
1.19 if (curl == NULL)
1.20 return 1;
1.21
1.22 - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
1.23 - fp = fopen("primary.xml.gz", "w");
1.24 - curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
1.25 - curl_easy_setopt(curl, CURLOPT_URL, REPO_URL "/primary.xml.gz");
1.26 - res = curl_easy_perform(curl);
1.27 - fclose(fp);
1.28 + if (stat("primary.xml.gz", &buf) < 0) {
1.29 + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
1.30 + fp = fopen("primary.xml.gz", "w");
1.31 + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
1.32 + curl_easy_setopt(curl, CURLOPT_URL,
1.33 + REPO_URL "/primary.xml.gz");
1.34 + res = curl_easy_perform(curl);
1.35 + fclose(fp);
1.36 + }
1.37
1.38 - fp = fopen("filelists.xml.gz", "w");
1.39 - curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
1.40 - curl_easy_setopt(curl, CURLOPT_URL, REPO_URL "/filelists.xml.gz");
1.41 - res = curl_easy_perform(curl);
1.42 - fclose(fp);
1.43 + if (stat("filelist.xml.gz", &buf) < 0) {
1.44 + fp = fopen("filelists.xml.gz", "w");
1.45 + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
1.46 + curl_easy_setopt(curl, CURLOPT_URL,
1.47 + REPO_URL "/filelists.xml.gz");
1.48 + res = curl_easy_perform(curl);
1.49 + fclose(fp);
1.50 + }
1.51
1.52 curl_easy_cleanup(curl);
1.53