diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2011-10-19 12:14:14 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2011-10-19 12:14:14 +0000 |
| commit | d8cbe08301a630951057ce5b6cff1189bd5573d7 (patch) | |
| tree | 9eec81a23ae6ac5aac4037175877c6ce99a4105d /usr.bin | |
| parent | d4108ed63dae98f081cbf2a190d444ac7429e030 (diff) | |
Notes
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/fetch/fetch.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index 7553bd8d1028..11b714fe4cd7 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -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 */ @@ -534,7 +540,7 @@ fetch(char *URL, const char *path) goto failure; } /* we got it, open local file */ - if ((of = fopen(path, "a")) == NULL) { + if ((of = fopen(path, "r+")) == NULL) { warn("%s: fopen()", path); goto failure; } @@ -551,8 +557,16 @@ 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 && fseeko(of, url->offset, SEEK_SET) != 0) { + warn("%s: fseeko()", path); + fclose(of); + of = NULL; + /* picked up again later */ + } } else if (m_flag && sb.st_size != -1) { /* mirror mode, local file exists */ if (sb.st_size == us.size && sb.st_mtime == us.mtime) |
