0bfc44e10a7e52c9435a8be1aba871ce19cc509d braney Thu Aug 18 12:30:00 2011 -0700 check to see if hub is okay after adding a myHub #4679 diff --git src/hg/lib/hubConnect.c src/hg/lib/hubConnect.c index 510a5f9..ee0de34 100644 --- src/hg/lib/hubConnect.c +++ src/hg/lib/hubConnect.c @@ -426,85 +426,87 @@ enterHubInStatus(tHub, unlisted); } else { warn("requested hub at %s does not have data for %s\n", url, database); return 0; } trackHubClose(&tHub); char *errorMessage = NULL; id = getHubId(url, &errorMessage); return id; } -static void getAndSetHubStatus(char *database, struct cart *cart, char *url, +static unsigned getAndSetHubStatus(char *database, struct cart *cart, char *url, boolean set, boolean unlisted) { char *errorMessage = NULL; unsigned id; if ((id = getHubId(url, &errorMessage)) == 0) { if ((id = fetchHub(database, url, unlisted)) == 0) - return; + return id; } else if (!hubHasDatabase(id, database)) { warn("requested hub at %s does not have data for %s\n", url, database); - return; + return id; } char hubName[32]; safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, id); if (set) cartSetString(cart, hubName, "1"); + +return id; } 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); if ((id = getHubId(url, errorMessage)) == 0) errAbort("inserted new hubUrl %s, but cannot find it", url); return id; } -boolean hubCheckForNew(char *database, struct cart *cart) -/* see if the user just typed in a new hub url, return TRUE if so */ +unsigned 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); + unsigned id = getAndSetHubStatus(database, cart, url, TRUE, TRUE); cartRemove(cart, hgHubDataText); - return TRUE; + return id; } -return FALSE; +return 0; } 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\"", hubStatusTableName, url); unsigned id = sqlQuickNum(conn, query); if (id == 0) errAbort("could not find url %s in status table (%s)\n", url, hubStatusTableName);