be4311c07e14feb728abc6425ee606ffaa611a58 markd Fri Jan 22 06:46:58 2021 -0800 merge with master diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c index 7e119c9..075ab64 100644 --- src/hg/lib/hdb.c +++ src/hg/lib/hdb.c @@ -921,31 +921,31 @@ return (count >= 0 && count <= HDB_MAX_SEQS_FOR_SPLIT); } static void tableListHashAdd(struct hash *dbTblHash, char *profile, char *db) /* Add to a hash that maps a track/table name (unsplit) to an slName list * of actual table names (possibly split) -- we can compute this once and * cache it to save a lot of querying if we will check existence of * lots of tables. */ { if (trackHubDatabase(db)) { struct trackHub *hub = hubConnectGetHubForDb(db); if (hub != NULL) { struct trackHubGenome *hubGenome = trackHubFindGenome(hub, db); - struct trackDb *tdbList = trackHubTracksForGenome(hub, hubGenome), *tdb; + struct trackDb *tdbList = trackHubTracksForGenome(hub, hubGenome, NULL), *tdb; for (tdb = tdbList; tdb != NULL; tdb = tdb->next) { hashAdd(dbTblHash, tdb->table, slNameNew(tdb->table)); } } return; } struct sqlConnection *conn = hAllocConnProfileMaybe(profile, db); if (conn == NULL) // Database does not exist, so no tables in the database exist -- leave the hash empty. return; struct slName *allTables = sqlListTables(conn); if (!sameString(CUSTOM_TRASH,db) && !sameString("hgFixed",db) && hCanHaveSplitTables(db)) { @@ -3920,60 +3920,77 @@ if (loadOneTrackDb(db, where, one->name, &tdbList, loaded)) foundOne = TRUE; } if (!foundOne) errAbort("can not find any trackDb tables for %s, check db.trackDb specification in hg.conf", db); slNameFreeList(&tableList); hashFree(&loaded); /* fill in supertrack fields, if any in settings */ trackDbSuperMarkup(tdbList); trackDbAddTableField(tdbList); return tdbList; } -boolean trackDataAccessible(char *database, struct trackDb *tdb) +boolean trackDataAccessibleRemote(char *database, struct trackDb *tdb, char *remoteLogin) /* Return TRUE if underlying data are accessible - meaning the track has either * a bigDataUrl with remote URL (http:// etc), a bigDataUrl with an existing local file, * or a database table with the same name. - * Note: this returns FALSE for composite tracks; use this on subtracks or simple tracks. */ + * Note: this returns FALSE for composite tracks; use this on subtracks or simple tracks. + * + * if remoteLogin is not NULL, use it when looking for the file */ { if (startsWith("mathWig", tdb->type)) return TRUE; // assume mathWig data is available. Fail at load time if it isn't char *bigDataUrl = trackDbSetting(tdb, "bigDataUrl"); if (bigDataUrl != NULL) { bigDataUrl = replaceChars(bigDataUrl, "$D", database); char *bigDataUrlLocal = hReplaceGbdb(bigDataUrl); if (hasProtocol(bigDataUrlLocal)) return TRUE; else + { + if (remoteLogin == NULL) return fileExists(bigDataUrlLocal); + else + return remoteFileExists(remoteLogin, bigDataUrlLocal); + } } else { // we now allow references to native tracks in track hubs tdb->table = trackHubSkipHubName(tdb->table); // if it's copied from a custom track, wait to find data later if (isCustomTrack(tdb->table)) return TRUE; return (hTableForTrack(database, tdb->table) != NULL); } } +boolean trackDataAccessible(char *database, struct trackDb *tdb) +/* Return TRUE if underlying data are accessible - meaning the track has either + * a bigDataUrl with remote URL (http:// etc), a bigDataUrl with an existing local file, + * or a database table with the same name. + * Note: this returns FALSE for composite tracks; use this on subtracks or simple tracks. */ +{ +return trackDataAccessibleRemote(database, tdb, NULL); +} + + static void addTrackIfDataAccessible(char *database, struct trackDb *tdb, boolean privateHost, struct trackDb **tdbRetList) /* check if a trackDb entry should be included in display, and if so * add it to the list, otherwise free it */ { if ((!tdb->private || privateHost) && trackDataAccessible(database, tdb)) slAddHead(tdbRetList, tdb); else if (tdbIsDownloadsOnly(tdb)) { // While it would be good to make table NULL, since we should support tracks // without tables (composties, etc) and even data tracks without tables (bigWigs). // However, some CGIs still need careful bullet-proofing. I have done so with // hgTrackUi, hgTracks, hgTable and hgGenome //if (tdb->table != NULL && sameString(tdb->table,tdb->track)) // tdb->table = NULL;