79bdb4a22380475a4ae7697a8045fff7fe543e33 chmalee Thu Jan 30 17:51:14 2020 -0800 Making hubClone use the udcCache specified in ~/.hg.conf if it's set instead of the udc default /tmp/udcCache location, refs Jorge email diff --git src/hg/utils/hubClone/hubClone.c src/hg/utils/hubClone/hubClone.c index 209b235..5787fd9 100644 --- src/hg/utils/hubClone/hubClone.c +++ src/hg/utils/hubClone/hubClone.c @@ -1,26 +1,27 @@ /* hubClone - Clone the hub text files to a local copy, fixing up bigDataUrls * to remote location if necessary. */ #include "common.h" #include "linefile.h" #include "hash.h" #include "options.h" #include "trackDb.h" #include "cart.h" // can't include trackHub.h without this? #include "trackHub.h" #include "errCatch.h" #include "ra.h" +#include "hui.h" void usage() /* Explain usage and exit. */ { errAbort( "hubClone - Clone the remote hub text files to a local copy in newDirectoryName, fixing up bigDataUrls to remote location if necessary\n" "usage:\n" " hubClone http://url/to/hub.txt\n" "options:\n" " -udcDir=/dir/to/udcCache Path to udc directory\n" " -download Download data files in addition to the hub configuration files\n" ); } /* Command line validation table. */ @@ -99,31 +100,34 @@ tdbFileName = (char *)hel->val; fprintf(out, "%s %s/%s\n", hel->name, genome, tdbFileName); } } else fprintf(out, "%s %s\n", hel->name, (char *)hel->val); } } fprintf(out, "\n"); hashElFreeList(&helList); } #define READ_SIZE 1024 * 1024 * 64 int downloadFile(FILE *f, char *url) /* Download a file in chunks, return -1 on error. Wrap in errCatch so - * we can keep downloading rest of hub files. */ + * we can keep downloading rest of hub files. + * For now using udc to read the files, but curl or wget would be preferred. + * The reason I'm not using them is because system() and popen don't honor + * SIGINT. */ { int ret = 0; struct errCatch *errCatch = errCatchNew(); if (errCatchStart(errCatch)) { struct udcFile *file = udcFileOpen(url, udcDefaultDir()); size_t size = READ_SIZE; off_t fileSize = udcFileSize(url); off_t counter = 0; char *buf = needLargeMem(size+1); while (counter < fileSize) { bits64 sizeRead = udcRead(file, buf, size); counter += sizeRead; mustWrite(f, buf, sizeRead); @@ -346,19 +350,20 @@ dyStringPrintf(downloadDir, "%s/%s/", hubName, genome->name); } tdbFileName = strrchr(genome->trackDbFile, '/') + 1; tdbFilePath = catTwoStrings(genomesDir, catTwoStrings("/", tdbFileName)); createWriteAndCloseFile(tdbFilePath, genome->trackDbFile, oneFile, dyStringContents(downloadDir)); } } } int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc < 2) usage(); +setUdcCacheDir(); udcSetDefaultDir(optionVal("udcDir", udcDefaultDir())); hubClone(argv[1], optionExists("download")); return 0; }