Skip to content

Commit

Permalink
mdeliver: preserve mtime in mrefile
Browse files Browse the repository at this point in the history
  • Loading branch information
leahneukirchen committed Feb 10, 2019
1 parent b85c56f commit 8d09a53
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mdeliver.c
Expand Up @@ -31,6 +31,7 @@ static char *Xflag;

char *targetdir;
long delivery;
int preserve_mtime;

char host[64];
void
Expand Down Expand Up @@ -187,6 +188,14 @@ deliver(FILE *infile)
blaze822_free(msg);
}

if (preserve_mtime) {
const struct timespec times[2] = {
{ tv.tv_sec, tv.tv_usec * 1000L },
st.st_mtim
};
utimensat(AT_FDCWD, tmp, times, 0);
}

snprintf(dst, sizeof dst, "%s/%s/%s:2,%s",
targetdir, (cflag || is_old) ? "cur" : "new", id,
Xflag ? Xflag : statusflags);
Expand Down Expand Up @@ -235,6 +244,7 @@ main(int argc, char *argv[])
// mrefile(1)

cflag = 1; // use cur/
preserve_mtime = 1;

int c;
while ((c = getopt(argc, argv, "kv")) != -1)
Expand Down

0 comments on commit 8d09a53

Please sign in to comment.