svn commit: r242615 - stable/7/usr.bin/fetch

Dag-Erling Smørgrav des at FreeBSD.org
Mon Nov 5 13:02:35 UTC 2012


Author: des
Date: Mon Nov  5 13:02:34 2012
New Revision: 242615
URL: http://svnweb.freebsd.org/changeset/base/242615

Log:
  MFH r225599: fix resume logic

Modified:
  stable/7/usr.bin/fetch/fetch.c
Directory Properties:
  stable/7/usr.bin/fetch/   (props changed)

Modified: stable/7/usr.bin/fetch/fetch.c
==============================================================================
--- stable/7/usr.bin/fetch/fetch.c	Mon Nov  5 12:58:44 2012	(r242614)
+++ stable/7/usr.bin/fetch/fetch.c	Mon Nov  5 13:02:34 2012	(r242615)
@@ -522,6 +522,12 @@ fetch(char *URL, const char *path)
 				    "does not match remote", path);
 				goto failure_keep;
 			}
+		} else if (url->offset > sb.st_size) {
+			/* gap between what we asked for and what we got */
+			warnx("%s: gap in resume mode", URL);
+			fclose(of);
+			of = NULL;
+			/* picked up again later */
 		} else if (us.size != -1) {
 			if (us.size == sb.st_size)
 				/* nothing to do */
@@ -551,6 +557,14 @@ fetch(char *URL, const char *path)
 				fclose(of);
 				of = NULL;
 				sb = nsb;
+				/* picked up again later */
+			}
+			/* seek to where we left off */
+			if (of != NULL && fseek(of, url->offset, SEEK_SET) != 0) {
+				warn("%s: fseek()", path);
+				fclose(of);
+				of = NULL;
+				/* picked up again later */
 			}
 		}
 	} else if (m_flag && sb.st_size != -1) {


More information about the svn-src-stable-7 mailing list