Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Nov 2012 13:02:34 +0000 (UTC)
From:      Dag-Erling Smørgrav <des@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r242615 - stable/7/usr.bin/fetch
Message-ID:  <201211051302.qA5D2Y8n004949@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211051302.qA5D2Y8n004949>