541933ca6a407a10621c3110fb0873529d78e11e
chmalee
  Wed Feb 26 12:42:38 2025 -0800
Don't error out if trying to do a hubspace re-upload of a file if the upload is coming from hubtools. Assume hubtools users want to overwrite existing files, ref Max email

diff --git src/hg/hgHubConnect/hooks/pre-finish.c src/hg/hgHubConnect/hooks/pre-finish.c
index 29c15dc897c..d70c4612af2 100644
--- src/hg/hgHubConnect/hooks/pre-finish.c
+++ src/hg/hgHubConnect/hooks/pre-finish.c
@@ -126,31 +126,33 @@
             userDataDir = dataDir = getDataDir(userName);
             struct dyString *newFile = dyStringNew(0);
             // if parentDir provided we are throwing the files in there
             if (parentDir)
                 {
                 encodedParentDir = encodePath(parentDir);
                 if (!endsWith(encodedParentDir, "/"))
                     encodedParentDir = catTwoStrings(encodedParentDir, "/");
                 dataDir = catTwoStrings(dataDir, encodedParentDir);
                 }
             dyStringPrintf(newFile, "%s%s", dataDir, fileName);
 
             fprintf(stderr, "moving %s to %s\n", tusFile, dyStringContents(newFile));
             // TODO: check if file exists or not and let user choose to overwrite
             // and re-call this hook, for now just exit if the file exists
-            if (fileExists(dyStringContents(newFile)))
+            // hubtools uploads always overwrite because we assume those users
+            // know what they are doing
+            if (fileExists(dyStringContents(newFile)) && !isHubToolsUpload)
                 {
                 errAbort("file '%s' exists already, not overwriting", dyStringContents(newFile));
                 }
             else
                 {
                 // set our mysql table location:
                 location = dyStringContents(newFile);
                 // the directory may not exist yet
                 int oldUmask = 00;
                 if (!isDirectory(dataDir))
                     {
                     fprintf(stderr, "making directory '%s'\n", dataDir);
                     // the directory needs to be 777, so ignore umask for now
                     oldUmask = umask(0);
                     makeDirsOnPath(dataDir);