a8c88d64b3a8adf8d6b522247b89c327b36e2a66 angie Mon Apr 29 10:41:21 2019 -0700 Don't create new userdata directory unless we have at least one file to store there. Thx Hiram diff --git src/hg/hgSession/sessionData.c src/hg/hgSession/sessionData.c index 9a31fff..826697a 100644 --- src/hg/hgSession/sessionData.c +++ src/hg/hgSession/sessionData.c @@ -79,32 +79,30 @@ * sessionDir; move trashPath to new path and soft-link from trashPath to new path. * If trashPath is already a soft-link, return the path that it links to. * Return NULL if trashPath does not exist (can happen with expired custom track files). */ { char *newPath = NULL; if (fileExists(trashPath)) { char *existingLink = maybeReadlink(trashPath); if (existingLink) newPath = existingLink; else { newPath = sessionDataPathFromTrash(trashPath, sessionDir); if (fileExists(newPath)) errAbort("saveTrashFile: new path '%s' already exists", newPath); - // If trashPath has subdirs, make sure those exist in newPath - if (strchr(trashPath+strlen(trashDir())+1, '/')) makeDirsForFile(newPath); moveAndLink(trashPath, newPath); } } return newPath; } static char *nextTrashPath(char *string, char *trashDirPrefix) /* Alloc & return the next file path in string that starts with "../trash/", or NULL. */ { char *trashPath = NULL; if (isNotEmpty(string)) { char *pathStart = stringIn(trashDirPrefix, string); if (pathStart) @@ -411,35 +409,30 @@ INLINE boolean cartVarIsCustomComposite(char *cartVar) /* Return TRUE if cartVar starts with "customComposite-". */ { return startsWith(customCompositeCartName "-", cartVar); } void saveSessionData(struct cart *cart, char *encUserName, char *encSessionName) /* If hg.conf specifies safe places to store files and/or tables that belong to user sessions, * then scan cart for trashDir files and/or customTrash tables, store them in safe locations, * and update cart to point to the new locations. */ { char *sessionDataDbPrefix = cfgOption("sessionDataDbPrefix"); char *sessionDataDir = cfgOption("sessionDataDir"); // Use (URL-encoded) userName and sessionName to make directory hierarchy under sessionDataDir char *sessionDir = sessionDirFromNames(sessionDataDir, encUserName, encSessionName); -if (isNotEmpty(sessionDir)) - { - makeDirsOnPath(sessionDir); - } - if (isNotEmpty(sessionDataDbPrefix) || isNotEmpty(sessionDir)) { struct slPair *allVars = cartVarsLike(cart, "*"); struct slPair *var; for (var = allVars; var != NULL; var = var->next) { if (startsWith(CT_FILE_VAR_PREFIX, var->name) || cartVarIsCustomComposite(var->name)) { // val is file that contains references to trash files and customTrash db tables; // replace with new file containing references to saved files and tables. char *oldTrackFile = cloneString(var->val); char *newTrackFile = saveTrackFile(cart, var->name, var->val, sessionDataDbPrefix, sessionDir); if (newTrackFile && cartVarIsCustomComposite(var->name))