1ae84cc8ece407ee1646cd2812eb715c30255550
braney
  Thu Jul 21 14:38:48 2011 -0700
changes out of code review  #4647
diff --git src/hg/lib/hubConnect.c src/hg/lib/hubConnect.c
index edbd575..af6584d 100644
--- src/hg/lib/hubConnect.c
+++ src/hg/lib/hubConnect.c
@@ -476,63 +476,56 @@
 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 */
 {
 char *url = cartOptionalString(cart, hgHubDataText);
 
 if (url != NULL)
     {
-    stripChar(url, ' ');
+    trimSpaces(url);
     getAndSetHubStatus(database, cart, url, TRUE, TRUE);
     cartRemove(cart, hgHubDataText);
     return TRUE;
     }
 return FALSE;
 }
 
-void hubClearStatus(char *url)
+unsigned hubClearStatus(char *url)
+/* drop the information about this url from the hubStatus table */
 {
 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);
 
 safef(query, sizeof(query), "delete from %s where hubUrl = \"%s\"", hubStatusTableName, url);
 
 sqlUpdate(conn, query);
 hDisconnectCentral(&conn);
+
+return id;
 }
 
 void hubDisconnect(struct cart *cart, char *url)
+/* drop the information about this url from the hubStatus table, and 
+ * the cart variable the references this hub */
 {
-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);
-
-safef(query, sizeof(query), "delete from %s where hubUrl = \"%s\"", hubStatusTableName, url);
-
-sqlUpdate(conn, query);
-hDisconnectCentral(&conn);
+/* clear the hubStatus table */
+unsigned id = hubClearStatus(url);
 
+/* remove the cart variable */
 char buffer[1024];
-
 safef(buffer, sizeof buffer, "hgHubConnect.hub.%d", id);
 cartRemove(cart, buffer);
 }