23b10b9fed9b850a60b7f601c6275811caa812e6 angie Mon Dec 3 11:43:50 2018 -0800 Don't reuse trash files where it can be avoided -- make new cart files when there are changes, so that we don't have to copy files every time we save or load a session. refs #22440 diff --git src/hg/near/hgNear/customColumn.c src/hg/near/hgNear/customColumn.c index bc0bde1..7d35b6a 100644 --- src/hg/near/hgNear/customColumn.c +++ src/hg/near/hgNear/customColumn.c @@ -20,36 +20,35 @@ { char *fileName = NULL; if (cartVarExists(cart, customFileVarName)) { fileName = cartString(cart, customFileVarName); if (!fileExists(fileName)) { cartRemove(cart, customFileVarName); fileName = NULL; } } return fileName; } static char *newCustomFileName() -/* Create new custom file name and add it to cart. */ +/* Create new custom file name. */ { struct tempName tn; makeTempName(&tn, "near", ".col"); -cartSetString(cart, customFileVarName, tn.forCgi); -return cartString(cart, customFileVarName); +return cloneString(tn.forCgi); } void doCustomPage(struct sqlConnection *conn, struct column *colList) /* Put up page to input custom columns. */ { makeTitle("Setup Custom Columns for Gene Sorter", "hgNearHelp.html#Custom"); hPrintf("
\n"); cartSaveSession(cart); /* Put up descriptive text. */ controlPanelStart(); hPrintf( "Add your own custom columns to the Gene Sorter using the " "" "format described here."); @@ -377,75 +376,65 @@ /* Remove any existing custom columns. */ { struct column *list = NULL, *col, *next; for (col = *pColList; col != NULL; col = next) { next = col->next; if (!startsWith("custom", col->type)) { slAddHead(&list, col); } } slReverse(&list); *pColList = list; } -static char *getDupedCustomFileName() -/* Get custom file name, recycling if possible. FreeMem this - * when done. */ -{ -char *fileName = customFileName(); -if (fileName == NULL) - fileName = newCustomFileName(); -return cloneString(fileName); -} - static void customFromText(struct sqlConnection *conn, char *text, struct column **pColList) /* Convert custom column text to lineFile, and call custom column * updater. */ { struct lineFile *lf = lineFileOnString("custom column", TRUE, text); -char *outFileName = getDupedCustomFileName(); +char *outFileName = newCustomFileName(); struct column *newList; FILE *f; struct hash *uniqHash = NULL; /* Remove file name from cart for better error recovery. */ cartRemove(cart, customFileVarName); /* Copy and verify output. */ f = mustOpen(outFileName, "w"); removeOldCustomColumns(pColList); uniqHash = hashColumns(*pColList); newList = verifyCopyColumns(conn, lf, f, *pColList, uniqHash); *pColList = slCat(*pColList, newList); lf->buf = NULL; /* Don't let lineFileClose free this */ lineFileClose(&lf); carefulClose(&f); /* Put back file name in cart , looks like we must have succeeded. */ cartSetString(cart, customFileVarName, outFileName); freez(&outFileName); freeHash(&uniqHash); } static void customFromUrls(struct sqlConnection *conn, char *urlList, struct column **pColList) /* Grab custom columns from a list of URLs. */ { -char *outFileName = getDupedCustomFileName(); +char *outFileName = newCustomFileName(); struct column *customCols = NULL; FILE *f; char *url; struct hash *uniqHash = NULL; /* Remove file name from cart for better error recovery. */ cartRemove(cart, customFileVarName); /* Copy and verify output. */ f = mustOpen(outFileName, "w"); removeOldCustomColumns(pColList); uniqHash = hashColumns(*pColList); /* Loop through and add columns from each URL. */ while ((url = nextWord(&urlList)) != NULL)