f4811acb1836d4a91ab6d2189aff8f1d7a438d1b chmalee Tue Feb 25 15:10:49 2025 -0800 Remove hubSpace hub from the cart when deleting a hub.txt, refs #31058 diff --git src/hg/hgHubConnect/trackHubWizard.c src/hg/hgHubConnect/trackHubWizard.c index 510c6f3f858..316199d6975 100644 --- src/hg/hgHubConnect/trackHubWizard.c +++ src/hg/hgHubConnect/trackHubWizard.c @@ -90,30 +90,44 @@ for (f = fileList; f != NULL; ) { struct jsonElement *fileObj = (struct jsonElement *)f->val; char *fileName = jsonStringField(fileObj, "fileName"); char *fileType = jsonStringField(fileObj, "fileType"); char *db = jsonStringField(fileObj, "genome"); char *fullPath = jsonStringField(fileObj, "fullPath"); copy = f->next; if (sameString(fileType, "dir")) { f->next = NULL; jsonListAdd(dirListJsonEle, fileObj); } else { + if (sameString(fileType, "hub.txt")) + { + // disconnect this hub from the cart if it exists + char *hubUrl = urlForFile(userName, fullPath); + char *hubId = hubNameFromUrl(hubUrl); + if (hubId) + { + /* remove the cart variable */ + hubId += 4; // skip past the hub_ part + char buffer[1024]; + safef(buffer, sizeof buffer, "hgHubConnect.hub.%s", hubId); + cartRemove(cj->cart, buffer); + } + } removeOneFile(userName, fileName, fullPath, db, fileType); // write out the fullPath so the DataTable can remove the correct row: jsonWriteString(cj->jw, NULL, fullPath); } f = copy; } // now attempt to delete any requested directories, but don't die if they still have contents sortByFullPath(dirListJsonEle); struct slRef *dir = NULL; for (dir = dirListJsonEle->val.jeList; dir != NULL; dir = dir->next) { struct jsonElement *fileObj = (struct jsonElement *)dir->val; char *fileName = jsonStringField(fileObj, "fileName"); char *fileType = jsonStringField(fileObj, "fileType"); char *db = jsonStringField(fileObj, "genome");