6627b1c33bdef1886f84fce4df14d0dd5c786657 chmalee Fri Mar 8 17:10:21 2024 -0800 Make the DataTable update dynamically. Correctly use a hidden file input to keep track of submitted and unsubmitted files diff --git src/hg/hgHubConnect/hooks/post-finish.c src/hg/hgHubConnect/hooks/post-finish.c index f704b47..04f2645 100644 --- src/hg/hgHubConnect/hooks/post-finish.c +++ src/hg/hgHubConnect/hooks/post-finish.c @@ -18,41 +18,30 @@ void usage() /* Explain usage and exit. */ { errAbort( "post-finish - tus daemon post-finish hook program\n" "usage:\n" " post-finish < input\n" ); } /* Command line validation table. */ static struct optionSpec options[] = { {NULL, 0}, }; -struct jsonElement *makeDefaultResponse() -/* Create the default response json with some fields pre-filled */ -{ -struct hash *defHash = hashNew(8); -struct jsonElement *response = newJsonObject(defHash); -// only the HTTP Response object is important to have by default, the other -// fields will be created as needed -jsonObjectAdd(response, HTTP_NAME, newJsonObject(hashNew(8))); -return response; -} - int postFinish() /* post-finish hook for tus daemon. Read JSON encoded hook request from * stdin and write a JSON encoded hook to stdout. Writing to stderr * will be redirected to the tusd log and not seen by the user, so for * errors that the user needs to see, they need to be in the JSON response */ { // TODO: create response object and do all error catching through that char *reqId = getenv("TUS_ID"); // always return an exit status to the daemon and print to stdout, as // stdout gets sent by the daemon back to the client int exitStatus = 0; struct jsonElement *response = makeDefaultResponse(); if (!(reqId)) { rejectUpload(response, "not a TUS request"); @@ -93,31 +82,31 @@ else if (tusFile == NULL) { rejectUpload(response, "No Event.Path setting"); exitStatus = -1; } else { char *tusInfo = catTwoStrings(tusFile, ".info"); char *dataDir = getDataDir(userName); char *newFile = catTwoStrings(dataDir, uploadFname); fprintf(stderr, "moving %s to %s\n", tusFile, newFile); // TODO: check if file exists or not and let user choose to overwrite // and re-call this hook, for now just exit if the file exists if (fileExists(newFile)) { - rejectUpload(response, "file '%s' exists already, not overwriting"); + rejectUpload(response, "file '%s' exists already, not overwriting", newFile); exitStatus = 1; } else { // the directory may not exist yet int oldUmask = 00; if (!isDirectory(dataDir)) { fprintf(stderr, "making directory '%s'\n", dataDir); // the directory needs to be 777, so ignore umask for now oldUmask = umask(0); makeDirsOnPath(dataDir); // restore umask umask(oldUmask); }