csomh / rpms / rsync

Forked from rpms/rsync 3 years ago
Clone
5ae4d2
From 0f8e9e2d8638e47d646a6baba694b303ac84e695 Mon Sep 17 00:00:00 2001
5ae4d2
From: Wayne Davison <wayned@samba.org>
5ae4d2
Date: Mon, 15 Jan 2018 10:52:15 -0800
5ae4d2
Subject: [PATCH 1/1] Don't force nanoseconds if a file wasn't transferred or
5ae4d2
 checksummed.
5ae4d2
5ae4d2
---
5ae4d2
 backup.c    | 2 +-
5ae4d2
 generator.c | 5 ++++-
5ae4d2
 rsync.c     | 6 +++---
5ae4d2
 rsync.h     | 1 +
5ae4d2
 4 files changed, 9 insertions(+), 5 deletions(-)
5ae4d2
5ae4d2
diff --git a/backup.c b/backup.c
5ae4d2
index bc565329..5f40b39a 100644
5ae4d2
--- a/backup.c
5ae4d2
+++ b/backup.c
5ae4d2
@@ -336,7 +336,7 @@ int make_backup(const char *fname, BOOL prefer_rename)
5ae4d2
 
5ae4d2
 	save_preserve_xattrs = preserve_xattrs;
5ae4d2
 	preserve_xattrs = 0;
5ae4d2
-	set_file_attrs(buf, file, NULL, fname, 0);
5ae4d2
+	set_file_attrs(buf, file, NULL, fname, ATTRS_SET_NANO);
5ae4d2
 	preserve_xattrs = save_preserve_xattrs;
5ae4d2
 
5ae4d2
 	unmake_file(file);
5ae4d2
diff --git a/generator.c b/generator.c
5ae4d2
index 4b0a60e4..a112da6e 100644
5ae4d2
--- a/generator.c
5ae4d2
+++ b/generator.c
5ae4d2
@@ -99,6 +99,7 @@ extern struct file_list *cur_flist, *first_flist, *dir_flist;
5ae4d2
 extern filter_rule_list filter_list, daemon_filter_list;
5ae4d2
 
5ae4d2
 int maybe_ATTRS_REPORT = 0;
5ae4d2
+int maybe_ATTRS_SET_NANO = 0;
5ae4d2
 
5ae4d2
 static dev_t dev_zero;
5ae4d2
 static int deldelay_size = 0, deldelay_cnt = 0;
5ae4d2
@@ -1214,6 +1215,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
5ae4d2
 		return;
5ae4d2
 	}
5ae4d2
 
5ae4d2
+	maybe_ATTRS_SET_NANO = always_checksum ? ATTRS_SET_NANO : 0;
5ae4d2
+
5ae4d2
 	if (skip_dir) {
5ae4d2
 		if (is_below(file, skip_dir)) {
5ae4d2
 			if (is_dir)
5ae4d2
@@ -1762,7 +1765,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
5ae4d2
 			do_unlink(partialptr);
5ae4d2
 			handle_partial_dir(partialptr, PDIR_DELETE);
5ae4d2
 		}
5ae4d2
-		set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT);
5ae4d2
+		set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT | maybe_ATTRS_SET_NANO);
5ae4d2
 		if (itemizing)
5ae4d2
 			itemize(fnamecmp, file, ndx, statret, &sx, 0, 0, NULL);
5ae4d2
 #ifdef SUPPORT_HARD_LINKS
5ae4d2
diff --git a/rsync.c b/rsync.c
5ae4d2
index ae036a6b..a0b948dc 100644
5ae4d2
--- a/rsync.c
5ae4d2
+++ b/rsync.c
5ae4d2
@@ -556,7 +556,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
5ae4d2
 	if (!(flags & ATTRS_SKIP_MTIME)
5ae4d2
 	 && (sxp->st.st_mtime != file->modtime
5ae4d2
 #ifdef ST_MTIME_NSEC
5ae4d2
-	  || (NSEC_BUMP(file) && (uint32)sxp->st.ST_MTIME_NSEC != F_MOD_NSEC(file))
5ae4d2
+	  || (flags & ATTRS_SET_NANO && NSEC_BUMP(file) && (uint32)sxp->st.ST_MTIME_NSEC != F_MOD_NSEC(file))
5ae4d2
 #endif
5ae4d2
 	  )) {
5ae4d2
 		int ret = set_modtime(fname, file->modtime, F_MOD_NSEC(file), sxp->st.st_mode);
5ae4d2
@@ -672,7 +672,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
5ae4d2
 
5ae4d2
 	/* Change permissions before putting the file into place. */
5ae4d2
 	set_file_attrs(fnametmp, file, NULL, fnamecmp,
5ae4d2
-		       ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
5ae4d2
+		       ok_to_set_time ? ATTRS_SET_NANO : ATTRS_SKIP_MTIME);
5ae4d2
 
5ae4d2
 	/* move tmp file over real file */
5ae4d2
 	if (DEBUG_GTE(RECV, 1))
5ae4d2
@@ -697,7 +697,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
5ae4d2
 
5ae4d2
   do_set_file_attrs:
5ae4d2
 	set_file_attrs(fnametmp, file, NULL, fnamecmp,
5ae4d2
-		       ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
5ae4d2
+		       ok_to_set_time ? ATTRS_SET_NANO : ATTRS_SKIP_MTIME);
5ae4d2
 
5ae4d2
 	if (temp_copy_name) {
5ae4d2
 		if (do_rename(fnametmp, fname) < 0) {
5ae4d2
diff --git a/rsync.h b/rsync.h
5ae4d2
index 6c732db3..53fff2d6 100644
5ae4d2
--- a/rsync.h
5ae4d2
+++ b/rsync.h
5ae4d2
@@ -165,6 +165,7 @@
5ae4d2
 
5ae4d2
 #define ATTRS_REPORT		(1<<0)
5ae4d2
 #define ATTRS_SKIP_MTIME	(1<<1)
5ae4d2
+#define ATTRS_SET_NANO		(1<<2)
5ae4d2
 
5ae4d2
 #define FULL_FLUSH	1
5ae4d2
 #define NORMAL_FLUSH	0
5ae4d2
-- 
5ae4d2
2.23.0