4a55f1d55a77c2c3a1e3e5b08d1efb369535d859 chmalee Fri Aug 1 15:14:31 2025 -0700 Prevent bug in tusd pre-finish hook where the hub.txt and container directory had the correct locations but the actual uploaded file had a symlinked location, which was throwing off the UI code that strips off the dataDir portion of the location diff --git src/hg/hgHubConnect/hooks/pre-finish.c src/hg/hgHubConnect/hooks/pre-finish.c index e135c7ab9f5..6d1dbaac34c 100644 --- src/hg/hgHubConnect/hooks/pre-finish.c +++ src/hg/hgHubConnect/hooks/pre-finish.c @@ -145,31 +145,44 @@ // we've passed all the checks so we can write a new or updated row // to the mysql table and return to the client that we were successful if (exitStatus == 0) { // create a hub for this upload, which can be edited later struct hubSpace *row = NULL; AllocVar(row); row->userName = userName; row->fileName = fileName; row->fileSize = fileSize; row->fileType = fileType; row->creationTime = NULL; // automatically handled by mysql row->lastModified = sqlUnixTimeToDate(&lastModified, TRUE); row->db = db; + // resolve any symlinks in the path, because tusd sets the path as + // the command line specified dataDir + pre-create's ChangeFileInfo + // this was leading to a bug where the uploaded file had the symlinked + // path, but the containing hub.txt and directory row had the realpath, + // which was causing confusion in the UI code + char *canonicalPath = realpath(tusFile, NULL); + if (canonicalPath != NULL) + row->location = canonicalPath; + else + { + // all upload data should have been received and thus the realpath + // should not fail, but just in case, put something valid here row->location = tusFile; + } row->md5sum = md5HexForFile(row->location); row->parentDir = encodedParentDir ? encodedParentDir : ""; if (!isHubToolsUpload && !(sameString(fileType, "hub.txt"))) { createNewTempHubForUpload(reqId, row, userDataDir, encodedParentDir); fprintf(stderr, "added hub.txt and hubSpace row for hub for file: '%s'\n", fileName); fflush(stderr); } // first make the parentDir rows makeParentDirRows(row->userName, sqlDateToUnixTime(row->lastModified), row->db, row->parentDir, userDataDir); row->parentDir = hubNameFromPath(encodedParentDir); addHubSpaceRowForFile(row); fprintf(stderr, "added hubSpace row for file '%s'\n", fileName); fflush(stderr); }