acdd3b5efa8944ca173016b6b0ce8170197c80f7
braney
  Tue Sep 12 12:48:48 2017 -0700
check for a disappearing custom hub

diff --git src/hg/lib/cart.c src/hg/lib/cart.c
index d606be5..411f0e7 100644
--- src/hg/lib/cart.c
+++ src/hg/lib/cart.c
@@ -301,30 +301,39 @@
 dyStringFree(&dy);
 }
 
 #ifndef GBROWSE
 static void copyCustomComposites(struct cart *cart, struct hashEl *el)
 /* Copy a set of custom composites to a new hub file. Update the 
  * relevant cart variables. */
 {
 struct tempName hubTn;
 char *hubFileVar = cloneString(el->name);
 char *db = el->name + sizeof(CUSTOM_COMPOSITE_SETTING);
 char *oldHubFileName = el->val;
 trashDirDateFile(&hubTn, "hgComposite", "hub", ".txt");
 char *newHubFileName = cloneString(hubTn.forCgi);
 
+// let's make sure the hub hasn't been cleaned up
+int fd = open(oldHubFileName, O_RDONLY);
+if (fd < 0)
+    {
+    cartRemove(cart, el->name);
+    return;
+    }
+
+close(fd);
 copyFile(oldHubFileName, newHubFileName);
 
 char *errorMessage;
 unsigned oldHubId =  hubFindOrAddUrlInStatusTable(db, cart, oldHubFileName, &errorMessage);
 unsigned newHubId =  hubFindOrAddUrlInStatusTable(db, cart, newHubFileName, &errorMessage);
 
 // need to change hgHubConnect.hub.#hubNumber# (connected hubs)
 struct slPair *hv, *hubVarList = cartVarsWithPrefix(cart, hgHubConnectHubVarPrefix);
 char buffer[4096];
 for(hv = hubVarList; hv; hv = hv->next)
     {
     unsigned hubId = sqlUnsigned(hv->name + strlen(hgHubConnectHubVarPrefix));
     
     if (hubId == oldHubId)
         {