int edwOpenAndRecordInDir(struct sqlConnection *conn, char *submitDir, char *submitFile, char *url, int *retHostId, int *retDirId) /* Return a low level read socket handle on URL if possible. Consult and * update the edwHost and edwDir tables to help log and troubleshoot remote * problems. The url parameter should be just a concatenation of submitDir and * submitFile. */ { /* Wrap routine to open network file in errCatch and remember whether it works. */ struct errCatch *errCatch = errCatchNew(); int sd = -1; boolean success = TRUE; if (errCatchStart(errCatch)) { sd = netUrlMustOpenPastHeader(url); } errCatchEnd(errCatch); if (errCatch->gotError) { success = FALSE; warn("Error: %s", trimSpaces(errCatch->message->string)); } /* Parse url into pieces */ struct netParsedUrl npu; ZeroVar(&npu); netParseUrl(url, &npu); char urlDir[PATH_LEN], urlFileName[PATH_LEN], urlExtension[PATH_LEN]; splitPath(npu.file, urlDir, urlFileName, urlExtension); /* Record success of open attempt in host and submitDir tables. */ int hostId = edwGetHost(conn, npu.host); recordIntoHistory(conn, hostId, "edwHost", success); int submitDirId = edwGetSubmitDir(conn, hostId, submitDir); recordIntoHistory(conn, submitDirId, "edwSubmitDir", success); /* Finish up error processing, bailing out of further processing if there was an error. */ errCatchFree(&errCatch); if (!success) noWarnAbort(); /* Update optional return variables and return socket to read from. */ if (retHostId != NULL) *retHostId = hostId; if (retDirId != NULL) *retDirId = submitDirId; return sd; }
void submitUrl(struct sqlConnection *conn) /* Submit validated manifest if it is not already in process. Show * progress once it is in progress. */ { /* Parse email and URL out of CGI vars. Do a tiny bit of error checking. */ char *url = trimSpaces(cgiString("url")); if (!stringIn("://", url)) errAbort("%s doesn't seem to be a valid URL, no '://'", url); /* Do some reality checks that email and URL actually exist. */ edwMustGetUserFromEmail(conn, userEmail); int sd = netUrlMustOpenPastHeader(url); close(sd); edwAddSubmitJob(conn, userEmail, url, cgiBoolean("update")); /* Give the system a half second to react and then put up status info about submission */ sleep1000(1000); monitorSubmission(conn); }