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");
printf(", tsv");
printf(", csv)");
}
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("
\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 (%lld files)",fileCount);
int fileId = getRecentSubmitFileId(conn, submitDirId, "meta.txt");
- if (cdwCheckFileAccess(conn, fileId, user))
+ if ((fileId > 0) && cdwCheckFileAccess(conn, fileId, user))
{
printf(" (metadata: html");
doServeTagStorm(conn, datasetId);
}
}
else // Otherwise print a label and description.
{
printf("- %s (%s)
\n", label, datasetId);
printf("%s\n", desc);
}
printf(" \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("- %s (%s)
\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: html");
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);