7545a188d43c6e1ea33f692b0d833ec96a7f76c5
chmalee
  Wed Aug 14 09:21:15 2024 -0700
refactor some methods into userdata.c for writing hub.txt files. Finish trackHubWizard.c back end for writing hub.txt and clean up the html. Start of adding a modal dialog for creating hub.txt

diff --git src/hg/hgHubConnect/hooks/post-finish.c src/hg/hgHubConnect/hooks/post-finish.c
index c40092e..c5e5c07 100644
--- src/hg/hgHubConnect/hooks/post-finish.c
+++ src/hg/hgHubConnect/hooks/post-finish.c
@@ -129,57 +129,31 @@
                         umask(oldUmask);
                         }
                     copyFile(tusFile, newFile);
                     // the files definitely should not be executable!
                     chmod(newFile, 0666);
                     mustRemove(tusFile);
                     mustRemove(tusInfo);
                     }
                 }
             }
 
         // 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)
             {
-            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->hubNameList = NULL;
-            row->db = db;
-            row->location = location;
-            row->md5sum = md5HexForFile(row->location);
-            struct sqlConnection *conn = hConnectCentral();
-
-            // now write out row to hubSpace table
-            if (!sqlTableExistsOnMain(conn, "hubSpace"))
-                {
-                errAbort("No hubSpace MySQL table is present. Please send us an email");
-                }
-            struct dyString *sqlUpdateStmt = dyStringNew(0);
-            sqlDyStringPrintf(sqlUpdateStmt, "insert into hubSpace values ('%s', '%s', %llu, "
-                    "'%s', NULL, '%s', '', '%s', '%s', '%s')",
-                    row->userName, row->fileName, row->fileSize, row->fileType,
-                    row->lastModified, row->db, row->location, row->md5sum);
-            fprintf(stderr, "%s\n", sqlUpdateStmt->string);
-            fflush(stderr);
-            sqlUpdate(conn, sqlUpdateStmt->string);
+            addNewFileForUser(userName, fileName, fileSize, fileType, lastModified, NULL, db, location);
             }
         }
     if (errCatch->gotError)
         {
         rejectUpload(response, errCatch->message->string);
         exitStatus = 1;
         }
     errCatchEnd(errCatch);
     }
 // always print a response no matter what
 jsonPrintToFile(response, NULL, stdout, 0);
 return exitStatus;
 }
 
 int main(int argc, char *argv[])