e90f9ec1342f152874194ba7a24c21da11c0c868
max
  Tue Oct 17 05:54:55 2023 -0700
changes after code review, refs #32312

diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index af609ea..3893f82 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -1447,43 +1447,44 @@
 char *hReplaceGbdb(char* fileName)
  /* Returns a gbdb filename, potentially rewriting it according to hg.conf
   * If the settings gbdbLoc1 and gbdbLoc2 are found, try them in order, by
   * replacing /gbdb/ with the new locations.
   * Typically, gbdbLoc1 is /gbdb/ and gbdbLoc2 is http://hgdownload.soe.ucsc.edu/gbdb/
   * If after the replacement of gbdbLoc1 the resulting fileName does not exist,
   * gbdbLoc2 is used.
   * This function does not guarantee that the returned filename exists.
   * We assume /gbdb/ does not appear somewhere inside a fileName.
   * Result has to be free'd.
  * */
 {
 if (fileName == NULL)
     return fileName;
 
-// if the gbdbLoc2 system is not used at all, like on the RR, stop now. 
+// 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 going over trackDb.
-char* newGbdbLoc = cfgOption("gbdbLoc2");
-if (newGbdbLoc == NULL || !startsWith("/gbdb/", fileName))
+// 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;
 
 freeMem(path);
-path = replaceChars(fileName, "/gbdb/", newGbdbLoc);
+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.
 */