757e45a5277d0cea141c10dadb0a24f62b5734d4 braney Tue Jun 1 17:49:00 2021 -0700 wnen inserting rows in hubStatus, catch and ignore duplicate entries due t new unique index on hubUrl diff --git src/hg/lib/hubConnect.c src/hg/lib/hubConnect.c index 970d5bb..fa6e9a4 100644 --- src/hg/lib/hubConnect.c +++ src/hg/lib/hubConnect.c @@ -427,36 +427,49 @@ dbCount++; dyStringPrintf(dy,"%s,", hel->name); } *pCount = dbCount; return dy->string; } static void insertHubUrlInStatus(char *url) /* add a url to the hubStatus table */ { struct sqlConnection *conn = hConnectCentral(); char query[4096]; char *statusTable = getHubStatusTableName(); +struct errCatch *errCatch = errCatchNew(); +if (errCatchStart(errCatch)) + { if (sqlFieldIndex(conn, statusTable, "firstAdded") >= 0) sqlSafef(query, sizeof(query), "insert into %s (hubUrl,shortLabel,longLabel,dbCount,dbList,status,lastOkTime,lastNotOkTime,errorMessage,firstAdded) values (\"%s\",\"\",\"\",0,NULL,0,\"\",\"\",\"\",now())", statusTable, url); else sqlSafef(query, sizeof(query), "insert into %s (hubUrl) values (\"%s\")", statusTable, url); sqlUpdate(conn, query); + } +errCatchEnd(errCatch); +if (errCatch->gotError) + { + // if we got a duplicate error, it means this hubUrl is already in the + // hubStatus table. + const char *error = sqlLastError(conn); + if (!startsWith("Duplicate entry", error)) + errAbort("%s", error); + } hDisconnectCentral(&conn); } static unsigned getHubId(char *url, char **errorMessage) /* find id for url in hubStatus table */ { struct sqlConnection *conn = hConnectCentral(); char query[4096]; char **row; boolean foundOne = FALSE; int id = 0; char *statusTableName = getHubStatusTableName(); sqlSafef(query, sizeof(query), "select id,errorMessage from %s where hubUrl = \"%s\"", statusTableName, url);