diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -176,7 +176,20 @@ int main(int argc, char *argv[]) /* When blender is finished, run this... */ fprintf(stderr, "Finished frame %d in job %d, uploading...", framenum, jobnum); - curlpost(pathtoOutput, urltoOutput); /* uploads (HTML POST) the output at outputpath to the server at outputurl */ + 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. Trying again..."); + int tries=0; + while(tries<10 && curlpost(pathtoOutput, urltoOutput)){ + fprintf(stderr, "Upload failed. Trying again in 10 seconds... (attempt %d of 10)", tries); + tries++; + sleep(10); + } + // @TODO: Keep track of files that we were unable to upload, and upload them later + } free(urltoOutput); free(pathtoOutput); @@ -185,13 +198,14 @@ int main(int argc, char *argv[]) } else fprintf(stderr,"Nothing to do. Idling...\n"); + // If the server says that every frame for the last jobnum is finished, OR if the data is getting old if(1 == 0){ + // Note: individual frames are already deleted after uploading, + // except for ones that couldn't be uploaded delete_jobdata(jobnum, datadir); } - - sleep(5); // Poll 5 seconds. @TODO: Remove all polling } return 0;