summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2019-02-10 21:23:09 +0100
committerLeah Neukirchen <leah@vuxu.org>2019-02-10 21:23:09 +0100
commit8d09a5339e18735d7492e3fe178edbad6abad3f0 (patch)
tree4ff760db71360883a3ec9be00c46732b2dca37d1
parentb85c56f30ce1a5b9cb4de6dffea126f1af745066 (diff)
downloadmblaze-8d09a5339e18735d7492e3fe178edbad6abad3f0.tar.gz
mblaze-8d09a5339e18735d7492e3fe178edbad6abad3f0.tar.xz
mblaze-8d09a5339e18735d7492e3fe178edbad6abad3f0.zip
mdeliver: preserve mtime in mrefile
-rw-r--r--mdeliver.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/mdeliver.c b/mdeliver.c
index 7af186a..f300222 100644
--- a/mdeliver.c
+++ b/mdeliver.c
@@ -31,6 +31,7 @@ static char *Xflag;
 
 char *targetdir;
 long delivery;
+int preserve_mtime;
 
 char host[64];
 void
@@ -187,6 +188,14 @@ tryagain:
 			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);
@@ -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)