On Sat, 23 Sep 2017, Jesper Wallin wrote:
...
> The patch below will use the Last-Modified header in order to set the
> modification time for http or https links. I also added, what to me
> looked like a missing "\n" on the error message in ftp.c.
...
> --- fetch.c 7 Mar 2017 08:00:23 -0000 1.163
> +++ fetch.c 22 Sep 2017 19:52:49 -0000
...
> @@ -1043,8 +1050,22 @@ cleanup_url_get:
> fclose(fin);
> else if (s != -1)
> close(s);
> - if (out >= 0 && out != fileno(stdout))
> + if (out >= 0 && out != fileno(stdout)) {
> +
> + if (mtime != -1) {
> + struct timeval tv[2];
> + tv[0].tv_sec = time(NULL);
> + tv[0].tv_usec = tv[1].tv_usec = 0;
> + tv[1].tv_sec = mtime;
> +
> + if (futimes(out, tv) == -1)
I would avoid the time() call and use UTIME_NOW and futimens() instead:
if (mtime != -1) {
struct timespec ts[2];
ts[0].tv_nsec = UTIME_NOW;
ts[1].tv_sec = mtime;
tv[1].tv_nsec = 0;
if (futimens(out, ts) == -1)
> + fprintf(ttyout,
> + "Can't change modification time on %s to %s\n",
> + savefile, asctime(localtime(&mtime)));
asctime(localtime(x)) == ctime(x)
Philip Guenther