diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) - fprintf(stderr, "Loading config (fasten your seatbelts for a SEGFAULT :-D )...\n"); + fprintf(stderr, "Loading config...\n"); fprintf(stderr, "Connecting to server...\n"); @@ -169,30 +169,15 @@ int main(int argc, char *argv[]) // Variable Preparation _distren_asprintf(&jobdatapath, "job%d", jobnum); - _distren_asprintf(&urltoTar, "http://protofusion.org/distren/stor/job%d/job%d.tar.gz", jobnum); // Prepares URL to download from + _distren_asprintf(&urltoTar, "http://data.distren.org/job%d/job%d.tar.gz", jobnum); // Prepares URL to download from _distren_asprintf(&pathtoTar, "%s/stor/jobdata/job%d.tar.gz", datadir, jobnum); // Prepares destination to save to _distren_asprintf(&pathtoJobfile, "%s/%s/job.blend", datadir, jobdatapath ); // Prepares the path to the jobfile - _distren_asprintf(&urltoOutput, "http://protofusion.org/distren/stor/tmp/", jobdatapath ); // Prepares the URL where output is posted + _distren_asprintf(&urltoOutput, "http://data.distren.org/tmp/", jobdatapath ); // Prepares the URL where output is posted _distren_asprintf(&pathtoXml, "%s/job%d/job%d.xml", datadir, jobnum ); // Prepares the path to the job's XML file free(jobdatapath); - // Prepare to download the job tar if it isn't present - struct stat buffer; - int fstatus = stat(pathtoJobfile, &buffer); - if(fstatus == -1) - { - // Download the Tar - if( curlget(urltoTar, pathtoTar) == 0){ - fprintf(stderr, "Job data retrieved successfully\n"); - free(urltoTar); - } - else { - fprintf(stderr, "Downloading job data from %s failed. Check your network connection.\n",urltoTar); - return 1; // Eventually make a retry loop - } - } - else - fprintf(stderr, "Using cached job file...\n"); + if(downloadTar(urltoTar, pathtoTar)) + return 1; _distren_asprintf(&outdir, "/tmp/distren/job%d", jobnum); mkdir("/tmp/distren", 0750); /* @FIXME: Change to tmpdir once it exists */ @@ -236,23 +221,9 @@ int main(int argc, char *argv[]) /* Post-execution */ fprintf(stderr, "Finished frame %d in job %d, uploading...\n", framenum, jobnum); - if( !curlpost(pathtoOutput, urltoOutput)) // Uploads output - { - fprintf(stderr,"Upload successful, removing old output...\n"); - remove(pathtoOutput); // Delete the file after its uploaded - } - else - { - fprintf(stderr,"Upload failed. Check your network connection. Retrying upload...\n"); - int tries=1; - while(tries<=10 && curlpost(pathtoOutput, urltoOutput)) - { - fprintf(stderr, "Upload failed. Trying again in 10 seconds... (attempt %d of 10)\n", tries); - tries++; - sleep(10); - } - // @FUTURE: Keep track of files that we were unable to upload, and upload them later - } + + uploadOutput(pathtoOutput, urltoOutput); // @TODO: Handle return value + free(urltoOutput); free(pathtoOutput);