8f2e6dbc0e250e934382477cea73e60624ccfe32
chmalee
  Fri Feb 16 11:45:42 2024 -0800
Start of populating a list of files to the UI

diff --git src/hg/lib/userdata.c src/hg/lib/userdata.c
index 0566c3f..07ebd7b 100644
--- src/hg/lib/userdata.c
+++ src/hg/lib/userdata.c
@@ -32,49 +32,63 @@
 if (userDataBaseDir[0] != '/')
     errAbort("config setting userDataDir must be an absolute path (starting with '/')");
 
 char *encUserName = cgiEncode(userName);
 char *userPrefix = md5HexForString(encUserName);
 userPrefix[2] = '\0';
 
 struct dyString *newDataDir = dyStringNew(0);
 dyStringPrintf(newDataDir, "%s/%s/%s/", 
     userDataBaseDir, userPrefix, encUserName);
 
 fprintf(stderr, "userDataDir = '%s'\n", newDataDir->string);
 return dyStringCannibalize(&newDataDir);
 }
 
-void removeTrack()
-/* Removes a custom track for this user */
+char *prefixUserFile(char *userName, char *fname)
+/* Allocate a new string that contains the full per-user path to fname, NULL otherwise */
 {
-//char *userName = getUserName();
+char *pathPrefix = getDataDir(userName);
+if (pathPrefix)
+    return catTwoStrings(pathPrefix, fname);
+else
+    return NULL;
+}
+
+void removeFileForUser(char *fname, char *userName)
+/* Remove a file for this user if it exists */
+{
+// The file to remove must be prefixed by the hg.conf userDataDir
+if (!startsWith(getDataDir(userName), fname))
+    return;
+if (fileExists(fname))
+    mustRemove(fname);
 }
 
 void uploadTrack()
 /* Saves a new track to the persistent storage for this user */
 {
 //char *userName = getUserName();
 }
 
 struct userFiles *listFilesForUser(char *userName)
 /* Get all the files for a particular user */
 {
 struct userFiles *userListing;
 AllocVar(userListing);
 char *path = getDataDir(userName);
-struct fileInfo *fiList = listDirX(path,NULL,TRUE);
+struct fileInfo *fiList = listDirX(path,NULL,FALSE);
 userListing->userName = userName;
 userListing->file = fiList;
 return userListing;
 }
 
 long long checkUserQuota(char *userName)
 /* Return the amount of space a user is currently using */
 {
 long long quota = 0;
 struct userFiles *ufList = listFilesForUser(userName);
 struct fileInfo *fi;
 if (ufList)
     {
     for (fi = ufList->file; fi != NULL; fi = fi->next)
         {