b67f28c479b6780e07033d2259d9592e7441db76 galt Fri Jun 25 04:19:56 2010 -0700 fixed minor bug needing to check eof right away; also added restartTotalDownloaded so that totalDownloaded gets tracked properly on auto-restart diff --git src/lib/net.c src/lib/net.c index 6030fdb..47b106b 100644 --- src/lib/net.c +++ src/lib/net.c @@ -1309,7 +1309,8 @@ } -boolean readParaFetchStatus(char *origPath, struct parallelConn **pPcList, char **pUrl, off_t *pFileSize, char **pDateString) +boolean readParaFetchStatus(char *origPath, + struct parallelConn **pPcList, char **pUrl, off_t *pFileSize, char **pDateString, off_t *pTotalDownloaded) /* Write a status file. * This has two purposes. * First, we can use it to resume a failed transfer. @@ -1320,6 +1321,7 @@ 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)) { @@ -1370,6 +1372,7 @@ pc->received = sqlLongLong(word); if (pc->received == pc->partSize) pc->sd = -1; /* part all done already */ + totalDownloaded += pc->received; slAddHead(&pcList, pc); } slReverse(&pcList); @@ -1387,6 +1390,7 @@ *pUrl = url; *pFileSize = fileSize; *pDateString = dateString; +*pTotalDownloaded = totalDownloaded; return TRUE; @@ -1489,7 +1493,8 @@ char *restartUrl = NULL; off_t restartFileSize = 0; char *restartDateString = ""; -boolean restartable = readParaFetchStatus(origPath, &restartPcList, &restartUrl, &restartFileSize, &restartDateString); +off_t restartTotalDownloaded = 0; +boolean restartable = readParaFetchStatus(origPath, &restartPcList, &restartUrl, &restartFileSize, &restartDateString, &restartTotalDownloaded); struct parallelConn *pcList = NULL, *pc; @@ -1499,6 +1504,7 @@ && sameString(dateString, restartDateString)) { pcList = restartPcList; + totalDownloaded = restartTotalDownloaded; } else { @@ -1543,6 +1549,16 @@ while (TRUE) { + /* are we done? */ + if (connOpen == 0) + { + boolean done = TRUE; + for(pc = pcList; pc; pc = pc->next) + if (pc->sd != -1) + done = FALSE; + if (done) break; + } + /* See if we need to open any connections, either new or retries */ for(pc = pcList; pc; pc = pc->next) { @@ -1708,16 +1724,6 @@ return FALSE; } - /* are we done? */ - if (connOpen == 0) - { - boolean done = TRUE; - for(pc = pcList; pc; pc = pc->next) - if (pc->sd != -1) - done = FALSE; - if (done) break; - } - } close(out);