5f283fb2e952aa7fa9a3d25f78ff234af5abd596 max Mon Feb 17 20:23:42 2014 -0800 making hgPcr target dbs work in the browserbox, refs #11957 diff --git src/hg/lib/targetDb.c src/hg/lib/targetDb.c index 2764bd4..55945e7 100644 --- src/hg/lib/targetDb.c +++ src/hg/lib/targetDb.c @@ -1,24 +1,26 @@ /* targetDb.c was originally generated by the autoSql program, which also * generated targetDb.h and targetDb.sql. This module links the database and * the RAM representation of objects. */ #include "common.h" #include "linefile.h" #include "dystring.h" #include "jksql.h" #include "targetDb.h" +#include "udc.h" +#include "hdb.h" void targetDbStaticLoad(char **row, struct targetDb *ret) /* Load a row from targetDb table into ret. The contents of ret will * be replaced at the next call to this function. */ { ret->name = row[0]; ret->description = row[1]; ret->db = row[2]; ret->pslTable = row[3]; ret->seqTable = row[4]; ret->extFileTable = row[5]; ret->seqFile = row[6]; ret->priority = sqlFloat(row[7]); @@ -27,31 +29,31 @@ } struct targetDb *targetDbLoad(char **row) /* Load a targetDb from row fetched with select * from targetDb * from database. Dispose of this with targetDbFree(). */ { struct targetDb *ret; AllocVar(ret); ret->name = cloneString(row[0]); ret->description = cloneString(row[1]); ret->db = cloneString(row[2]); ret->pslTable = cloneString(row[3]); ret->seqTable = cloneString(row[4]); ret->extFileTable = cloneString(row[5]); -ret->seqFile = cloneString(row[6]); +ret->seqFile = hReplaceGbdb(row[6]); ret->priority = sqlFloat(row[7]); ret->time = cloneString(row[8]); ret->settings = cloneString(row[9]); return ret; } struct targetDb *targetDbLoadAll(char *fileName) /* Load all targetDb from a whitespace-separated file. * Dispose of this with targetDbFreeList(). */ { struct targetDb *list = NULL, *el; struct lineFile *lf = lineFileOpen(fileName, TRUE); char *row[10]; while (lineFileRow(lf, row)) @@ -189,34 +191,49 @@ static boolean timeMoreRecentThanTable(int time, struct sqlConnection *conn, char *table) /* Return TRUE if the given UNIX time is more recent than the time that * table was last updated. */ { if (! sqlTableExists(conn, table)) return FALSE; long tableUpdateTime = sqlTableUpdateTime(conn, table); return (time > tableUpdateTime); } static boolean timeMoreRecentThanFile(long time, char *fileName) /* Return TRUE if the given UNIX time is more recent than the time that * fileName was last modified. */ { -if (! fileExists(fileName)) - return FALSE; -long fileUpdateTime = fileModTime(fileName); -return (time > fileUpdateTime); +bool ret = FALSE; +char *fileName2 = hReplaceGbdb(fileName); +if (fileExists(fileName2)) + { + long fileUpdateTime = fileModTime(fileName2); + ret = (time > fileUpdateTime); + } +else + // file is a http url + { + struct udcFile *uf = udcFileMayOpen(fileName2, NULL); + if (uf != NULL) + { + long urlUpdateTime = udcUpdateTime(uf); + ret = (time > urlUpdateTime); + } + } +freeMem(fileName2); +return ret; } struct targetDb *targetDbMaybeLoad(struct sqlConnection *conn, char **row) /* If row specifies a target whose tables and file exist, and are not newer * than target, allocate and return a targetDb; otherwise, return NULL * and log a warning to stderr for QA monitoring. */ { struct targetDb target; targetDbStaticLoad(row, &target); long time = sqlDateToUnixTime(target.time); if (timeMoreRecentThanTable(time, conn, target.pslTable) && (isEmpty(target.seqTable) || timeMoreRecentThanTable(time, conn, target.seqTable)) && (isEmpty(target.extFileTable) || timeMoreRecentThanTable(time, conn, target.extFileTable)) &&