Changeset - 4e072ce1165f
[Not reviewed]
default
0 2 0
Ethan Zonca (ethanzonca) - 16 years ago 2010-03-14 00:26:35
e@ethanzonca.com
Curlget updates and checks
2 files changed with 17 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/server/simpleslave.c
Show inline comments
 
@@ -154,11 +154,13 @@ int main(int argc, char *argv[])
 

	
 
        prepareJobPaths(jobnum, framenum, outputExt, datadir, &urltoTar, &pathtoTar, &pathtoJobfile, &urltoOutput, &pathtoOutput);
 
        // free(outputExt);
 

	
 
        if(downloadTar(urltoTar, pathtoTar))
 
          return 1;
 
        int dlret = downloadTar(urltoTar, pathtoTar);
 
        if(dlret == 0)
 
          fprintf(stderr,"Got data tarball\n");
 
        else if(dlret == 3)
 
          return 0; // ouput dir doesn't exist
 
        else
 
          fprintf(stderr,"Got data tarball\n");
 
          fprintf(stderr,"Using existing tarball...\n");
 

	
 
        unpackJob(datadir, pathtoTar);
 

	
src/server/slavefuncs.c
Show inline comments
 
@@ -155,7 +155,8 @@ int curlget(char *url, char *out){
 
  curl = curl_easy_init();
 
  if(curl) {
 
	outfile = fopen(out, "w"); // Open where we're writing to
 

	
 
    if(outfile == NULL)
 
      return 2; // Output dir doesn't exist
 
  curl_easy_setopt(curl, CURLOPT_URL, url);
 
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
 
  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writetodisk); // this MUST be set for win32 compat.
 
@@ -365,21 +366,28 @@ int downloadTar(char *url, char *destina
 
  if(fstatus == -1)
 
    {
 
      // Download the Tar
 
      if( curlget(url, destinationPath) == 0){
 
      int ret = curlget(url, destinationPath);
 
      if(ret == 0){
 
        fprintf(stderr, "Job data retrieved successfully\n");
 
        // free(url); @FIXME: causes doublefree! Curl must free the url?
 
        return 0;
 
      }
 
      else {
 
      else if(ret == 1){
 
        fprintf(stderr, "Downloading job data from %s failed. Check your network connection.\n",url);
 
        free(url);
 
        return 1; // Eventually make a retry loop
 
      }
 
      else if(ret == 2){
 
        fprintf(stderr, "Output directory \"%s\" does not exist!\n",destinationPath);
 
        free(url);
 
        return 3;
 
      }
 
    }
 
  else{
 
    fprintf(stderr, "Tar already exists! Download cancelled.\n");
 
    return 2;
 
  }
 

	
 
}
 

	
 

	
0 comments (0 inline, 0 general)