From 191098230b00ae3fab437f953a920be7d0cfb6e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 5 Nov 2007 21:55:31 -0500 Subject: [PATCH] Only download yum files if they're not there. --- main.c | 33 +++++++++++++++++++++------------ 1 files changed, 21 insertions(+), 12 deletions(-) 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); -- 1.7.1