summaryrefslogtreecommitdiffstats
path: root/usr.bin/fetch
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-08-12 12:55:26 +0000
committerjkh <jkh@FreeBSD.org>1996-08-12 12:55:26 +0000
commit633999a94babb0ab1ca53d9f3c8d9d8d70423752 (patch)
tree2f4a76597f4826fbb181b370dcfdc086b61ccba5 /usr.bin/fetch
parent3a66e92deb622840b3614a5b4d7c86eab8a6cbb4 (diff)
downloadFreeBSD-src-633999a94babb0ab1ca53d9f3c8d9d8d70423752.zip
FreeBSD-src-633999a94babb0ab1ca53d9f3c8d9d8d70423752.tar.gz
Fix broken modtime preservation code. *Now* it preserves the modtime
correctly! Noticed-By: knarf@camelot.de (Frank Bartels)
Diffstat (limited to 'usr.bin/fetch')
-rw-r--r--usr.bin/fetch/main.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/usr.bin/fetch/main.c b/usr.bin/fetch/main.c
index 5698a24..516113f 100644
--- a/usr.bin/fetch/main.c
+++ b/usr.bin/fetch/main.c
@@ -24,7 +24,7 @@
* SUCH DAMAGE.
*/
-/* $Id: main.c,v 1.12 1996/08/04 00:35:39 jmz Exp $ */
+/* $Id: main.c,v 1.13 1996/08/07 02:15:26 jkh Exp $ */
#include <stdlib.h>
#include <stdio.h>
@@ -66,7 +66,6 @@ int mirror = 0;
int newtime = 0;
int restart = 0;
time_t modtime;
-
FILE *file = 0;
void usage (), die (), rm (), t_out (), ftpget (), httpget (),
@@ -95,22 +94,29 @@ die ()
}
void
-rm ()
+adjmodtime()
{
- struct timeval tv[2];
- if (file) {
- fclose (file);
- if (file != stdout) {
- if (!restart && !mirror)
- remove (outputfile);
- else if (!mirror && !newtime) {
- tv[0].tv_usec = tv[1].tv_usec = 0;
- tv[0].tv_sec = time(0);
- tv[1].tv_sec = modtime;
- utimes (outputfile, tv);
- }
- }
+ struct timeval tv[2];
+
+ if (!newtime) {
+ tv[0].tv_usec = tv[1].tv_usec = 0;
+ tv[0].tv_sec = time(0);
+ tv[1].tv_sec = modtime;
+ utimes (outputfile, tv);
+ }
+}
+
+void
+rm()
+{
+ if (file) {
+ fclose (file);
+ if (file != stdout) {
+ if (!restart && !mirror)
+ remove (outputfile);
+ adjmodtime();
}
+ }
}
int
@@ -248,7 +254,7 @@ ftpget ()
restart = 0;
if (restart || mirror) {
f_size (outputfile, &size0, &t);
- if (mirror && size0 == size && modtime < t) {
+ if (mirror && size0 == size && modtime <= t) {
fclose(ftp);
return;
}
@@ -304,6 +310,8 @@ ftpget ()
fclose(fp);
fclose(file);
display (size, -1);
+ if (file != stdout)
+ adjmodtime();
exit (0);
}
OpenPOWER on IntegriCloud