759368142eec396d7b54ad72dc94a38459d1e3bf
chmalee
  Tue Dec 17 16:57:35 2024 -0800
Add a table with userName,quota to hgcentral so hubspace can have user-defined quotas, refs #31058

diff --git src/hg/lib/userdata.c src/hg/lib/userdata.c
index 115589c..2b1cc01 100644
--- src/hg/lib/userdata.c
+++ src/hg/lib/userdata.c
@@ -6,30 +6,31 @@
 
 #include "common.h"
 #include "hash.h"
 #include "portable.h"
 #include "trashDir.h"
 #include "md5.h"
 #include "hgConfig.h"
 #include "dystring.h"
 #include "cheapcgi.h"
 #include "customFactory.h"
 #include "wikiLink.h"
 #include "userdata.h"
 #include "jksql.h"
 #include "hdb.h"
 #include "hubSpace.h"
+#include "hubSpaceQuotas.h"
 
 char *getUserName()
 /* Query the right system for the users name */
 {
 return (loginSystemEnabled() || wikiLinkEnabled()) ? wikiLinkUserName() : NULL;
 }
 
 char *emailForUserName(char *userName)
 /* Fetch the email for this user from gbMembers hgcentral table */
 {
 struct sqlConnection *sc = hConnectCentral();
 struct dyString *query = sqlDyStringCreate("select email from gbMembers where userName = '%s'", userName);
 char *email = sqlQuickString(sc, dyStringCannibalize(&query));
 hDisconnectCentral(&sc);
 // this should be freeMem'd:
@@ -440,31 +441,32 @@
     // probably a common case
     return "defaultHub2";
 else
     {
     currHubName[defaultLen-1] = 0;
     currHubName += strlen(defaultHubName);
     int hubNum = sqlUnsigned(currHubName) + 1;
     struct dyString *hubName = dyStringCreate("%s%d", defaultHubName, hubNum);
     return dyStringCannibalize(&hubName);
     }
 }
 
 long long getMaxUserQuota(char *userName)
 /* Return how much space is allocated for this user or the default */
 {
-return HUB_SPACE_DEFAULT_QUOTA;
+long long specialQuota = quotaForUserName(userName);
+return specialQuota == 0 ? HUB_SPACE_DEFAULT_QUOTA : specialQuota;
 }
 
 long long checkUserQuota(char *userName)
 /* Return the amount of space a user is currently using */
 {
 long long quota = 0;
 struct hubSpace *hubSpace, *hubSpaceList = listFilesForUser(userName);
 for (hubSpace = hubSpaceList; hubSpace != NULL; hubSpace = hubSpace->next)
     {
     quota += hubSpace->fileSize;
     }
 return quota;
 }
 
 char *storeUserFile(char *userName, char *newFileName, void *data, size_t dataSize)