5fad625c42342d49423acd17a40d95357c3aae64
max
  Thu Oct 26 02:21:27 2023 -0700
changes after code review, refs #32498

diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index c062d9e..9dcad22 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -804,30 +804,33 @@
                  "settings in the hg.conf file and the databases they "
                  "specify.");
     }
 /* now that a profile has been determined, make sure this database goes
  * through that profile */
 sqlProfileAddDb(centralProfile, centralDb);
 sqlConnCacheDealloc(centralCc, &conn);
 sqlSetParanoid(FALSE);
 }
 
 struct sqlConnection *hConnectCentral()
 /* Connect to central database where user info and other info
  * not specific to a particular genome lives.  Free this up
  * with hDisconnectCentral(). */
 {
+if (hIsUcscHost())
+    sqlSetIsUcscMirror(TRUE);
+
 if (centralCc == NULL)
     hCentralMkCache();
 return sqlConnCacheAlloc(centralCc, centralDb);
 }
 
 void hDisconnectCentral(struct sqlConnection **pConn)
 /* Put back connection for reuse. */
 {
 if (*pConn != NULL)
     sqlConnCacheDealloc(centralCc, pConn);
 }
 
 static void hCartMkCache()
 /* Create the cart connection cache.  Defaults to the central connection
  * unless cart.db or cart.host are configured. */
@@ -1459,34 +1462,37 @@
 if (fileName == NULL)
     return fileName;
 
 // if the gbdbLoc1/gbdbLoc2 system is not used at all, like on the RR, do nothing and stop now. 
 // This is important, as we would be doing tens of thousands of stats
 // otherwise on the RR when we parse trackDb
 char* newGbdbLoc1 = cfgOption("gbdbLoc1");
 char* newGbdbLoc2 = cfgOption("gbdbLoc2");
 if ((newGbdbLoc1 == NULL && newGbdbLoc2==NULL) || !startsWith("/gbdb/", fileName))
     return cloneString(fileName);
 
 char *path = hReplaceGbdbLocal(fileName);
 if (fileExists(path))
     return path;
 
+if (newGbdbLoc2!=NULL)
+    {
     freeMem(path);
     path = replaceChars(fileName, "/gbdb/", newGbdbLoc2);
     if (cfgOptionBooleanDefault("traceGbdb", FALSE))
         fprintf(stderr, "REDIRECT gbdbLoc2 %s ", path);
+    }
 
 return path;
 }
 
 char *hReplaceGbdbSeqDir(char *path, char *db)
 /* similar to hReplaceGbdb, but accepts a nib or 2bit "directory" (basename) under
  * gbdb, like /gbdb/hg19 (which by jkLib is translated to /gbdb/hg19/hg19.2bit).
  hReplaceGbdb would check only if the dir exists. For 2bit basename, we
  have to check if the 2bit file exists, do the rewriting, then strip off the
  2bit filename again.
  This function works with .nib directories, but nib does not support opening
  from URLs.  As of Feb 2014, only hg16 and anoGam1 have no .2bit file.
 */
 {
 char buf[4096];
@@ -3517,30 +3523,42 @@
 }
 
 boolean hHostHasPrefix(char *prefix)
 /* Return TRUE if this is running on web-server with host name prefix */
 {
 if (prefix == NULL)
     return FALSE;
 
 char *httpHost = hHttpHost();
 if (httpHost == NULL)
     return FALSE;
 
 return startsWith(prefix, httpHost);
 }
 
+boolean hIsUcscHost()
+/* Return TRUE if this is one of our own servers: any regional node, beta or test. */
+{
+char *geoSuffix = cfgOption("browser.geoSuffix");
+fprintf(stderr, "Geo suffix is %s<br>", geoSuffix);
+if (geoSuffix)
+    return TRUE;
+if (hIsPrivateHost())
+    fprintf(stderr, "is private host<br>");
+return hIsPrivateHost() || hIsBetaHost();
+}
+
 boolean hIsPrivateHost()
 /* Return TRUE if this is running on private (development) web-server.
  * This was originally genome-test as well as hgwdev, however genome-test
  * may be repurposed to direct users to the preview site instead of development site. */
 {
 return hHostHasPrefix("hgwdev") || hHostHasPrefix("genome-test");  // FIXME: If genome-test
 }
 
 boolean hIsBetaHost()
 /* Return TRUE if this is running on beta (QA) web-server.
  * Use sparingly as behavior on beta should be as close to RR as possible. */
 {
 return hHostHasPrefix("hgwbeta");
 }