c248d6a10bcbdadcd7f2c7cfb0272dd73334faaf galt Fri Mar 22 23:33:49 2019 -0700 check that the file exists first. fixes bug in cdwWebBrowse when meta.txt is not found. discovered on public cirm with kriegsteinBrainOrganoid1. diff --git src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c index 77560e4..c901d73 100644 --- src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c +++ src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c @@ -1362,31 +1362,31 @@ printf(">text</A>"); printf(", <A HREF=\"cdwServeTagStorm?format=tsv&cdwDataSet=%s&%s\"", dataSet, cartSidUrlString(cart)); printf(">tsv</A>"); printf(", <A HREF=\"cdwServeTagStorm?format=csv&cdwDataSet=%s&%s\"", dataSet, cartSidUrlString(cart)); printf(">csv</A>)"); } int getRecentSubmitFileId(struct sqlConnection *conn, int submitDirId, char *submitFileName) /* Get the file ID of the most recent index.html file for dataset. */ { char query[PATH_LEN]; sqlSafef(query, sizeof(query), "select max(id) from cdwFile where submitFileName='%s' and submitDirId=%d", submitFileName, submitDirId); -return sqlQuickNum(conn, query); +return sqlQuickNum(conn, query); // returns 0 if none found } void doBrowseDatasets(struct sqlConnection *conn) /* Show datasets and links to dataset summary pages. */ { printf("<ul class='list-group'>\n"); char query[PATH_LEN]; sqlSafef(query, sizeof(query), "SELECT * FROM cdwDataset ORDER BY label "); struct cdwDataset *dataset, *datasetList = cdwDatasetLoadByQuery(conn, query); // Go through the cdwDataset table and generate an entry for each dataset. for (dataset = datasetList; dataset != NULL; dataset = dataset->next) { char *label = dataset->label; char *desc = dataset->description; char *datasetId = dataset->name; @@ -1402,31 +1402,31 @@ datasetId, label, datasetId); // Print out file count and descriptions. sqlSafef(query, sizeof(query), "select count(*) from %s where data_set_id='%s'", getCdwTableSetting("cdwFileTags"), datasetId); long long fileCount = sqlQuickLongLong(conn, query); // printf("%s (<A HREF=\"cdwWebBrowse?cdwCommand=browseFiles&cdwFile_filter=data_set_id%%3D+%%27%s%%27&%s\"", // desc, datasetId, cartSidUrlString(cart)); char varEqVal[256]; safef(varEqVal, sizeof(varEqVal), "data_set_id='%s'", datasetId); printf("%s (<A HREF=\"cdwWebBrowse?cdwCommand=browseFiles&cdwFile_filter=%s&%s\"", desc, cgiEncode(varEqVal), cartSidUrlString(cart)); printf(">%lld files</A>)",fileCount); int fileId = getRecentSubmitFileId(conn, submitDirId, "meta.txt"); - if (cdwCheckFileAccess(conn, fileId, user)) + if ((fileId > 0) && cdwCheckFileAccess(conn, fileId, user)) { printf(" (metadata: <A HREF=\"cdwWebBrowse?cdwCommand=dataSetMetaTree&cdwDataSet=%s&%s\"", datasetId, cartSidUrlString(cart)); printf(">html</A>"); doServeTagStorm(conn, datasetId); } } else // Otherwise print a label and description. { printf("<li class='list-group-item'><B>%s (%s)</B><BR>\n", label, datasetId); printf("%s\n", desc); } printf("</li>\n"); } cdwDatasetFree(&datasetList); @@ -1703,31 +1703,31 @@ // If the ID exists and the user has access print a link to the page. boolean haveAccess = ((fileId > 0) && cdwCheckFileAccess(conn, fileId, user)); if (haveAccess) { printf("<LI><B><A href=\"cdwGetFile/%s/summary/index.html\">%s (%s)</A></B><BR>\n", datasetId, label, datasetId); // Print out file count and descriptions. sqlSafef(query, sizeof(query), "select count(*) from %s where data_set_id='%s'", getCdwTableSetting("cdwFileTags"), datasetId); //long long fileCount = sqlQuickLongLong(conn, query); printf("%s", desc); char metaFileName[PATH_LEN]; safef(metaFileName, sizeof(metaFileName), "%s/%s", datasetId, "meta.txt"); int fileId = cdwFileIdFromPathSuffix(conn, metaFileName); - if (cdwCheckFileAccess(conn, fileId, user)) + if ((fileId > 0) && cdwCheckFileAccess(conn, fileId, user)) { printf(" (metadata: <A HREF=\"cdwWebBrowse?cdwCommand=dataSetMetaTree&cdwDataSet=%s&%s\"", datasetId, cartSidUrlString(cart)); printf(">html</A>"); doServeTagStorm(conn, datasetId); } struct slName *dataset, *dataSetNames=charSepToSlNames(jointDataset->childrenNames, *","); printf("("); int totFileCount = 0; // Go through each sub dataset, print a link into the search files and count total files. for (dataset = dataSetNames; dataset != NULL; dataset=dataset->next) { sqlSafef(query, sizeof(query), "select count(*) from %s where data_set_id='%s'", getCdwTableSetting("cdwFileTags"), dataset->name);