From: Kristian Høgsberg Date: Tue, 6 Nov 2007 02:55:31 +0000 (-0500) Subject: Only download yum files if they're not there. X-Git-Tag: 0.1~288 X-Git-Url: http://project.juiblex.co.uk/git/?a=commitdiff_plain;h=191098230b00ae3fab437f953a920be7d0cfb6e4;p=razor2.git%2F.git Only download yum files if they're not there. --- diff --git a/main.c b/main.c index 267753c..546fca8 100644 --- a/main.c +++ b/main.c @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include #include @@ -149,23 +151,30 @@ command_import_yum(int argc, const char *argv[]) CURL *curl; CURLcode res; FILE *fp; + struct stat buf; curl = curl_easy_init(); if (curl == NULL) return 1; - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); - fp = fopen("primary.xml.gz", "w"); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); - curl_easy_setopt(curl, CURLOPT_URL, REPO_URL "/primary.xml.gz"); - res = curl_easy_perform(curl); - fclose(fp); - - fp = fopen("filelists.xml.gz", "w"); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); - curl_easy_setopt(curl, CURLOPT_URL, REPO_URL "/filelists.xml.gz"); - res = curl_easy_perform(curl); - fclose(fp); + if (stat("primary.xml.gz", &buf) < 0) { + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); + fp = fopen("primary.xml.gz", "w"); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + curl_easy_setopt(curl, CURLOPT_URL, + REPO_URL "/primary.xml.gz"); + res = curl_easy_perform(curl); + fclose(fp); + } + + if (stat("filelist.xml.gz", &buf) < 0) { + fp = fopen("filelists.xml.gz", "w"); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + curl_easy_setopt(curl, CURLOPT_URL, + REPO_URL "/filelists.xml.gz"); + res = curl_easy_perform(curl); + fclose(fp); + } curl_easy_cleanup(curl);