f65a2b3c5cce9a173c871fc40e41881d08f5def9
kent
  Mon Jul 8 13:52:38 2013 -0700
Adding paraFetchTempUpdateTime for tracking file progress.
diff --git src/lib/paraFetch.c src/lib/paraFetch.c
index 7b28efe..354a320 100644
--- src/lib/paraFetch.c
+++ src/lib/paraFetch.c
@@ -1,27 +1,28 @@
 /* paraFetch - fetch things from remote URLs in parallel. */
 
 #include <utime.h>
 #include "common.h"
 #include "internet.h"
 #include "errabort.h"
 #include "hash.h"
 #include "linefile.h"
 #include "net.h"
 #include "https.h"
 #include "sqlNum.h"
 #include "obscure.h"
+#include "portable.h"
 #include "paraFetch.h"
 
 
 static void paraFetchWriteStatus(char *origPath, struct parallelConn *pcList, 
     char *url, off_t fileSize, char *dateString, boolean isFinal)
 /* Write a status file.
  * This has two purposes.
  * First, we can use it to resume a failed transfer.
  * Second, we can use it to follow progress */
 {
 char outTempX[1024];
 char outTemp[1024];
 safef(outTempX, sizeof(outTempX), "%s.paraFetchStatusX", origPath);
 safef(outTemp, sizeof(outTemp), "%s.paraFetchStatus", origPath);
 struct parallelConn *pc = NULL;
@@ -38,30 +39,47 @@
 	, (long long)pc->partSize
 	, (long long)pc->received);
     ++part;
     }
 
 carefulClose(&f);
 
 /* rename the successful status to the original name */
 rename(outTempX, outTemp);
 
 if (isFinal)  /* We are done and just looking to get rid of the file. */
     unlink(outTemp);
 }
 
 
+time_t paraFetchTempUpdateTime(char *origPath)
+/* Return last mod date of temp file - which is useful to see if process has stalled. */
+{
+char outTemp[1024];
+safef(outTemp, sizeof(outTemp), "%s.paraFetch", origPath);
+if (fileExists(outTemp))
+    return fileModTime(outTemp);
+else if (fileExists(origPath))
+    return fileModTime(origPath);
+else
+    {
+    errAbort("%s doesn't exist", origPath);
+    return 0;
+    }
+}
+
+
 boolean paraFetchReadStatus(char *origPath, 
     struct parallelConn **pPcList, char **pUrl, off_t *pFileSize, 
     char **pDateString, off_t *pTotalDownloaded)
 /* Read a status file - which is just origPath plus .paraFetchStatus.  This is updated during 
  * transit by parallelFetch. Returns FALSE if status file not there - possibly because
  * transfer is finished.  Any of the return parameters (pThis and pThat) may be NULL */
 {
 char outTemp[1024];
 char outStat[1024];
 safef(outStat, sizeof(outStat), "%s.paraFetchStatus", origPath);
 safef(outTemp, sizeof(outTemp), "%s.paraFetch", origPath);
 struct parallelConn *pcList = NULL, *pc = NULL;
 off_t totalDownloaded = 0;
 
 if (!fileExists(outStat))