0b0c072d96f3cf26f44d724353e4a48ba78d57b5 galt Sat Mar 26 11:53:05 2011 -0700 fixing FTP UTC time converted to localtime for udc, removed 1 debug comment, expanded comment about ftp time being UTC diff --git src/lib/udc.c src/lib/udc.c index 7e0ec7c..23ed308 100644 --- src/lib/udc.c +++ src/lib/udc.c @@ -386,54 +386,62 @@ } } struct tm tm; time_t t; // Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT // This will always be GMT if (strptime(lastModString, "%a, %d %b %Y %H:%M:%S %Z", &tm) == NULL) { /* Handle error */; hashFree(&hash); errAbort("unable to parse last-modified string [%s]", lastModString); } t = mktimeFromUtc(&tm); if (t == -1) { /* Handle error */; hashFree(&hash); - errAbort("mktimeFromUtc failed while converting last-modified string [%s] to UTC time", lastModString); + errAbort("mktimeFromUtc failed while converting last-modified string [%s] from UTC time", lastModString); } retInfo->updateTime = t; hashFree(&hash); return status; } /********* Section for ftp protocol **********/ // fetchData method: See udcDataViaHttpOrFtp above. boolean udcInfoViaFtp(char *url, struct udcRemoteFileInfo *retInfo) /* Gets size and last modified time of FTP URL */ { verbose(2, "checking ftp remote info on %s\n", url); long long size = 0; -time_t t; +time_t t, tUtc; +struct tm *tm = NULL; // TODO: would be nice to add int *retCtrlSocket to netGetFtpInfo so we can stash // in retInfo->connInfo and keep socket open. -boolean ok = netGetFtpInfo(url, &size, &t); +boolean ok = netGetFtpInfo(url, &size, &tUtc); if (!ok) return FALSE; +// Convert UTC to localtime +tm = gmtime(&tUtc); +t = mktimeFromUtc(tm); +if (t == -1) + { /* Handle error */; + errAbort("mktimeFromUtc failed while converting FTP UTC last-modified time %ld to local time", (long) tUtc); + } retInfo->size = size; retInfo->updateTime = t; return TRUE; } /********* Non-protocol-specific bits **********/ static char *fileNameInCacheDir(struct udcFile *file, char *fileName) /* Return the name of a file in the cache dir, from the cache root directory on down. * Do a freeMem on this when done. */ { int dirLen = strlen(file->cacheDir); int nameLen = strlen(fileName);