42e4fcaeceaed8da9e9ddcad54e120677194a9e4
braney
  Wed Jun 12 15:18:57 2019 -0700
add caching expiration on trackDb cache

diff --git src/hg/lib/hubConnect.c src/hg/lib/hubConnect.c
index 21f63de..e12c10e 100644
--- src/hg/lib/hubConnect.c
+++ src/hg/lib/hubConnect.c
@@ -10,31 +10,31 @@
 #include "common.h"
 #include "linefile.h"
 #include "hash.h"
 #include "dystring.h"
 #include "sqlNum.h"
 #include "jksql.h"
 #include "hdb.h"
 #include "net.h"
 #include "trackHub.h"
 #include "hubConnect.h"
 #include "hui.h"
 #include "errCatch.h"
 #include "obscure.h"
 #include "hgConfig.h"
 #include "grp.h"
-
+#include "udc.h"
 
 boolean isHubTrack(char *trackName)
 /* Return TRUE if it's a hub track. */
 {
 return startsWith(hubTrackPrefix, trackName);
 }
 
 static char *hubStatusTableName = NULL;
 static char *_hubPublicTableName = NULL;
 
 static char *getHubStatusTableName()
 /* return the hubStatus table name from the environment, 
  * or hg.conf, or use the default.  Cache the result */
 {
 if (hubStatusTableName == NULL)
@@ -712,46 +712,51 @@
 {
 /* Load trackDb.ra file and make it into proper trackDb tree */
 struct trackDb *tdbList = NULL;
 struct trackHub *trackHub = hub->trackHub;
 
 if (trackHub != NULL)
     {
     struct trackHubGenome *hubGenome = trackHubFindGenome(trackHub, database);
     if (hubGenome != NULL)
 	{
         boolean doCache = FALSE;
         if (sameOk(cfgOption("cacheTrackDb"), "on"))
             doCache = TRUE;
         if (doCache)
             {
-            struct trackDb *cacheTdb = trackDbHubCache(hub->hubUrl, hubGenome->name);
+            // we have to open the trackDb file to get the udc cache to check for an update
+            struct udcFile *checkCache = udcFileMayOpen(hubGenome->trackDbFile, NULL);
+            udcFileClose(&checkCache);
+
+            time_t time = udcTimeFromCache(hubGenome->trackDbFile, NULL);
+            struct trackDb *cacheTdb = trackDbHubCache(hubGenome->trackDbFile, time);
 
             if (cacheTdb != NULL)
                 return cacheTdb;
 
             memCheckPoint(); // we want to know how much memory is used to build the tdbList
             }
 
         tdbList = trackHubTracksForGenome(trackHub, hubGenome);
         tdbList = trackDbLinkUpGenerations(tdbList);
         tdbList = trackDbPolishAfterLinkup(tdbList, database);
         trackDbPrioritizeContainerItems(tdbList);
         trackHubPolishTrackNames(trackHub, tdbList);
 
         if (doCache)
-            trackDbHubCloneTdbListToSharedMem(hub->hubUrl, hubGenome->name, tdbList, memCheckPoint());
+            trackDbHubCloneTdbListToSharedMem(hubGenome->trackDbFile, tdbList, memCheckPoint());
 	}
     }
 return tdbList;
 }
 
 static struct grp *grpFromHub(struct hubConnectStatus *hub)
 /* Make up a grp structur from hub */
 {
 struct grp *grp;
 AllocVar(grp);
 char name[16];
 safef(name, sizeof(name), "hub_%d", hub->id);
 grp->name = cloneString(name);
 grp->label = cloneString(hub->trackHub->shortLabel);
 return grp;