627b526f8ff26ebb7539a5a6ee25f515a88242da
chmalee
  Tue Aug 6 15:10:06 2024 -0700
Can create a directory and place a hub.txt in it, and get an email for a userName

diff --git src/hg/hgHubConnect/trackHubWizard.c src/hg/hgHubConnect/trackHubWizard.c
index 74e29ce..5b27de0 100644
--- src/hg/hgHubConnect/trackHubWizard.c
+++ src/hg/hgHubConnect/trackHubWizard.c
@@ -7,30 +7,31 @@
 #include "cart.h"
 #include "cheapcgi.h"
 #include "hdb.h"
 #include "hgConfig.h"
 #include "md5.h"
 #include "trashDir.h"
 #include "hgHubConnect.h"
 #include "jsHelper.h"
 #include "web.h"
 #include "wikiLink.h"
 #include "customTrack.h"
 #include "userdata.h"
 #include "jsonWrite.h"
 #include "cartJson.h"
 #include "hubSpace.h"
+#include "hubConnect.h"
 
 void removeOneFile(char *userName, char *cgiFileName)
 /* Remove one single file for userName */
 {
 char *fileName = prefixUserFile(userName, cgiFileName);
 if (fileExists(fileName))
     {
     fprintf(stderr, "deleting file: '%s'\n", fileName);
     removeFileForUser(fileName, userName);
     fflush(stderr);
     }
 }
 
 void doRemoveFile(struct cartJson *cj, struct hash *paramHash)
 /* Process the request to remove a file */
@@ -46,70 +47,71 @@
     for (ele = deleteList; ele != NULL; ele = ele->next)
         {
         struct jsonElement *jsonVal = ele->val;
         removeOneFile(userName, jsonVal->val.jeString);
         jsonWriteString(cj->jw, NULL, jsonVal->val.jeString);
         }
     jsonWriteListEnd(cj->jw);
     }
 }
 
 void doMoveFile(struct cartJson *cj, struct hash *paramHash)
 /* Move a file to a new hub */
 {
 }
 
-static void writeHubText(struct trackHub *hub, char *hubDir, char *fileName, boolean makeDir)
+static void writeHubText(char *path, char *userName, char *hubName, char *db)
 /* Create a hub.txt file, optionally creating the directory holding it */
 {
 int oldUmask = 00;
 oldUmask = umask(0);
 makeDirsOnPath(path);
 // restore umask
 umask(oldUmask);
 // now make the hub.txt with some basic information
-char *hubFile = catTwoStrings(path, "hub.txt");
-maybeTouchFile(hubFile);
-struct dyString *contents = dyStringNew(0);
-dyStringPrintf(contents, "hub %s\nemail %s\nshortLabel %s\nlongLabel %s\nuseOneFile on\n\ngenome %s\n\n", name, userName, name, name, db);
+char *hubFile = catTwoStrings(path, "/hub.txt");
+FILE *f = mustOpen(hubFile, "w");
+fprintf(stderr, "would write \"hub %s\nemail %s\nshortLabel %s\nlongLabel %s\nuseOneFile on\n\ngenome %s\n\n\" to %s", hubName, emailForUserName(userName), hubName, hubName, db, hubFile);
+//fprintf(f, "hub %s\nemail %s\nshortLabel %s\nlongLabel %s\nuseOneFile on\n\ngenome %s\n\n", hubName, emailForUserName(userName), hubName, hubName, db);
+carefulClose(&f);
 }
 
 void doCreateHub(struct cartJson *cj, struct hash *paramHash)
 /* Make a new hub.txt with the parameters from the JSON request */
 {
 char *userName = getUserName();
 if (userName)
     {
     struct jsonWrite *errors = jsonWriteNew();
     // verify the arguments:
     (void)cartJsonRequiredParam(paramHash, "createHub", errors, "doCreateHub");
-    // params is an object with everything necessary to create a hub: name and assembly
-    struct hash *params = jsonObjectVal(hashFindVal(paramHash, "createHub"), "createHub");
-    char *db = hashFindVal(params, "db");
-    char *name = hashFindVal(params, "name");
+    // paramHash is an object with everything necessary to create a hub: name and assembly
+    char *db = jsonStringVal(hashFindVal(paramHash, "db"), "db");
+    char *name = jsonStringVal(hashFindVal(paramHash, "name"), "name");
     fprintf(stderr, "creating hub '%s' for db '%s'\n", name, db);
     fflush(stderr);
     // check if this hub already exists, must have a directory and hub.txt already:
     char *path = prefixUserFile(userName, name);
     if (isDirectory(path))
         {
         // can't make a hub that already exists!
         }
     else
         {
         // good we can make a new directory and stuff a hub.txt in it
         // the directory needs to be 777, so ignore umask for now
+        writeHubText(path, userName, name, db);
         }
     }
 fprintf(stderr, "Status: 204 No Content\n\n");
 fflush(stdout);
 exit(0);
 }
 
 static void outFilesForUser()
 /* List out the currently stored files for the user and their sizes */
 {
 char *userName = getUserName();
 struct jsonWrite *jw = jsonWriteNew(); // the JSON to return for the client javascript
 jsonWriteObjectStart(jw, NULL);
 if (userName)
     {