4c396a03784396605a6d9e2d698a7a999ab65d24 braney Wed Nov 30 20:04:14 2011 -0800 fix problems with status field in hubStatus not reflecting the actual state of the hubPublic table. We're no longer using the status field (#5965) diff --git src/hg/lib/hubConnect.c src/hg/lib/hubConnect.c index 2ffba5b..c15a741 100644 --- src/hg/lib/hubConnect.c +++ src/hg/lib/hubConnect.c @@ -112,37 +112,31 @@ boolean trackHubHasDatabase(struct trackHub *hub, char *database) /* Return TRUE if hub has contents for database */ { if (hub != NULL) { struct trackHubGenome *genomes = hub->genomeList; /* List of associated genomes. */ for(; genomes; genomes = genomes->next) if (sameString(genomes->name, database)) return TRUE; } return FALSE; } -boolean isHubUnlisted(struct hubConnectStatus *hub) -/* Return TRUE if it's an unlisted hub */ -{ - return (hub->status & HUB_UNLISTED); -} - -static struct trackHub *fetchHub(char *url, boolean unlisted, char **errorMessage) +static struct trackHub *fetchHub(char *url, char **errorMessage) { struct errCatch *errCatch = errCatchNew(); struct trackHub *tHub = NULL; boolean gotWarning = FALSE; if (errCatchStart(errCatch)) tHub = trackHubOpen(url, "1"); // open hub.. it'll get renamed later errCatchEnd(errCatch); if (errCatch->gotError) { gotWarning = TRUE; *errorMessage = cloneString(errCatch->message->string); } errCatchFree(&errCatch); @@ -161,31 +155,31 @@ struct hubConnectStatus *hub = NULL; char query[1024]; safef(query, sizeof(query), "select hubUrl,status, errorMessage from %s where id=%d", getHubStatusTableName(), id); struct sqlResult *sr = sqlGetResult(conn, query); char **row = sqlNextRow(sr); if (row != NULL) { AllocVar(hub); hub->id = id; hub->hubUrl = cloneString(row[0]); hub->status = sqlUnsigned(row[1]); char *errorMessage = cloneString(row[2]); if (isEmpty(errorMessage)) - hub->trackHub = fetchHub( hub->hubUrl, isHubUnlisted(hub), &errorMessage); + hub->trackHub = fetchHub( hub->hubUrl, &errorMessage); if (errorMessage != NULL) hub->errorMessage = cloneString(errorMessage); } sqlFreeResult(&sr); return hub; } struct hubConnectStatus *hubConnectStatusListFromCartAll(struct cart *cart) /* Return list of all track hubs that are referenced by cart. */ { struct hubConnectStatus *hubList = NULL, *hub; struct slPair *pair, *pairList = cartVarsWithPrefix(cart, hgHubConnectHubVarPrefix); struct sqlConnection *conn = hConnectCentral(); for (pair = pairList; pair != NULL; pair = pair->next) @@ -351,38 +345,38 @@ { struct hashEl *hel; struct dyString *dy = newDyString(1024); struct hashCookie cookie = hashFirst(tHub->genomeHash); int dbCount = 0; while ((hel = hashNext(&cookie)) != NULL) { dbCount++; dyStringPrintf(dy,"%s,", hel->name); } *pCount = dbCount; return dy->string; } -static void insertHubUrlInStatus(char *url, boolean unlisted) +static void insertHubUrlInStatus(char *url) /* add a url to the hubStatus table */ { struct sqlConnection *conn = hConnectCentral(); char query[512]; -safef(query, sizeof(query), "insert into %s (hubUrl,status) values (\"%s\",%d)", - getHubStatusTableName(), url, unlisted ? 1 : 0); +safef(query, sizeof(query), "insert into %s (hubUrl) values (\"%s\")", + getHubStatusTableName(), url); sqlUpdate(conn, query); hDisconnectCentral(&conn); } static unsigned getHubId(char *url, char **errorMessage) /* find id for url in hubStatus table */ { struct sqlConnection *conn = hConnectCentral(); char query[512]; char **row; boolean foundOne = FALSE; int id = 0; char *statusTableName = getHubStatusTableName(); safef(query, sizeof(query), "select id,errorMessage from %s where hubUrl = \"%s\"", statusTableName, url); @@ -400,104 +394,104 @@ char *thisId = row[0], *thisError = row[1]; if (!isEmpty(thisError)) *errorMessage = cloneString(thisError); id = sqlUnsigned(thisId); } sqlFreeResult(&sr); hDisconnectCentral(&conn); return id; } static void getAndSetHubStatus(char *database, struct cart *cart, char *url, - boolean set, boolean unlisted) + boolean set) /* make sure url is in hubStatus table, fetch the hub to get latest * labels and db information. * Set the cart variable to turn the hub on if set == TRUE. */ { char *errorMessage = NULL; unsigned id; /* first see if url is in hubStatus table */ if ((id = getHubId(url, &errorMessage)) == 0) { /* the url is not in the hubStatus table, add it */ - insertHubUrlInStatus(url, unlisted); + insertHubUrlInStatus(url); if ((id = getHubId(url, &errorMessage)) == 0) { errAbort("opened hub, but could not get it out of the hubStatus table"); } } /* allocate a hub */ struct hubConnectStatus *hub = NULL; AllocVar(hub); hub->id = id; hub->hubUrl = cloneString(url); /* new fetch the contents of the hub to fill in the status table */ -struct trackHub *tHub = fetchHub( url, unlisted, &errorMessage); +struct trackHub *tHub = fetchHub( url, &errorMessage); if (tHub != NULL) hub->trackHub = tHub; /* update the status table with the lastest label and database information */ hubUpdateStatus( errorMessage, hub); /* if we're turning on the hub, set the cart variable */ if (set) { char hubName[32]; safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, id); cartSetString(cart, hubName, "1"); } hubConnectStatusFree(&hub); } unsigned hubFindOrAddUrlInStatusTable(char *database, struct cart *cart, char *url, char **errorMessage) /* find this url in the status table, and return its id and errorMessage (if an errorMessage exists) */ { int id = 0; *errorMessage = NULL; if ((id = getHubId(url, errorMessage)) > 0) return id; -getAndSetHubStatus(database, cart, url, FALSE, FALSE); +getAndSetHubStatus(database, cart, url, FALSE); if ((id = getHubId(url, errorMessage)) == 0) errAbort("inserted new hubUrl %s, but cannot find it", url); return id; } void hubCheckForNew(char *database, struct cart *cart) /* see if the user just typed in a new hub url, return id if so */ { char *url = cartOptionalString(cart, hgHubDataText); if (url != NULL) { trimSpaces(url); - getAndSetHubStatus(database, cart, url, TRUE, TRUE); + getAndSetHubStatus(database, cart, url, TRUE); cartRemove(cart, hgHubDataText); } } unsigned hubResetError(char *url) /* clear the error for this url in the hubStatus table,return the id */ { struct sqlConnection *conn = hConnectCentral(); char query[512]; safef(query, sizeof(query), "select id from %s where hubUrl = \"%s\"", getHubStatusTableName(), url); unsigned id = sqlQuickNum(conn, query); if (id == 0) errAbort("could not find url %s in status table (%s)\n",