diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2000-12-27 16:42:09 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2000-12-27 16:42:09 +0000 |
| commit | 77f06ddeb1fdf996b8a33f5c4068e5dc1ba237b4 (patch) | |
| tree | 9f4023163dd8801a1cca5c4b543c16f942f102eb /usr.bin/fetch | |
| parent | 0d8db7eaa5d0c1249aaff4eca4cbcfdfb3df71f9 (diff) | |
Notes
Diffstat (limited to 'usr.bin/fetch')
| -rw-r--r-- | usr.bin/fetch/fetch.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index c24d288659a4..a0796a76eb65 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -197,6 +197,16 @@ fetch(char *URL, char *path) goto failure; } + /* if no scheme was specified, take a guess */ + if (!*url->scheme) { + if (!*url->host) + strcpy(url->scheme, SCHEME_FILE); + else if (strncasecmp(url->host, "ftp.", 4)) + strcpy(url->scheme, SCHEME_FTP); + else if (strncasecmp(url->host, "www.", 4)) + strcpy(url->scheme, SCHEME_HTTP); + } + timeout = 0; *flags = 0; count = 0; @@ -295,12 +305,15 @@ fetch(char *URL, char *path) goto success; } + if (us.size == -1) + warnx("%s: size of remote file is not known", path); if (v_level > 1) { if (sb.st_size != -1) fprintf(stderr, "local size / mtime: %lld / %ld\n", sb.st_size, sb.st_mtime); - fprintf(stderr, "remote size / mtime: %lld / %ld\n", - us.size, us.mtime); + if (us.size != -1) + fprintf(stderr, "remote size / mtime: %lld / %ld\n", + us.size, us.mtime); } /* open output file */ @@ -312,6 +325,12 @@ fetch(char *URL, char *path) if (!F_flag && us.mtime && sb.st_mtime != us.mtime) { /* no match! have to refetch */ fclose(f); + /* if precious, warn the user and give up */ + if (R_flag) { + warnx("%s: local modification time does not match remote", + path); + goto failure_keep; + } url->offset = 0; if ((f = fetchXGet(url, &us, flags)) == NULL) { warnx("%s: %s", path, fetchLastErrString); |
