src/hg/lib/customFactory.c 1.113

1.113 2009/12/10 20:02:23 hiram
unlink the custom wia file after it is open so it will disappear if the loader fails
Index: src/hg/lib/customFactory.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/customFactory.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -b -B -U 4 -r1.112 -r1.113
--- src/hg/lib/customFactory.c	9 Dec 2009 19:26:12 -0000	1.112
+++ src/hg/lib/customFactory.c	10 Dec 2009 20:02:23 -0000	1.113
@@ -1318,8 +1318,9 @@
     FILE *out = pipelineFile(dataPipe);
     char c;
     int fputcErr = 0;
 
+    unlink(wigAscii);/* stays open, disappears when close or pipe fail */
     while ((c = fgetc(in)) != EOF && fputcErr != EOF)
 	fputcErr = fputc(c, out);
     carefulClose(&in);
     fflush(out);		/* help see error from loader failure */
@@ -1361,10 +1362,10 @@
     if (options.wibSizeLimit >= 300000000)
 	warn("warning: reached data limit for wiggle track '%s' "
 	     "%lld >= 300,000,000<BR>\n", 
 	     track->tdb->shortLabel, options.wibSizeLimit);
+    unlink(wigAscii);/* done with this, remove it */
     }
-unlink(wigAscii);/* done with this, remove it */
 freeMem(track->wigAscii);
 char tdbType[256];
 safef(tdbType, sizeof(tdbType), "wig %g %g", lowerLimit, upperLimit);
 track->tdb->type = cloneString(tdbType);