csomh / rpms / rsync

Forked from rpms/rsync 3 years ago
Clone
e7be50
commit bd17c2a4e237ca1f38544db65053ecfea6054009
e7be50
Author: Tomas Korbar <tkorbar@redhat.com>
e7be50
Date:   Thu Sep 24 13:17:45 2020 +0200
e7be50
e7be50
    Skip files for transfer that has been truncated during negotiation
e7be50
e7be50
diff --git a/rsync.1 b/rsync.1
e7be50
index 6cabd44..855dd47 100644
e7be50
--- a/rsync.1
e7be50
+++ b/rsync.1
e7be50
@@ -1004,8 +1004,10 @@ This causes rsync to update a file by appending data onto
e7be50
 the end of the file, which presumes that the data that already exists on
e7be50
 the receiving side is identical with the start of the file on the sending
e7be50
 side.  If a file needs to be transferred and its size on the receiver is
e7be50
-the same or longer than the size on the sender, the file is skipped.  This
e7be50
-does not interfere with the updating of a file\(cq\&s non\-content attributes
e7be50
+the same or longer than the size on the sender, the file is skipped. It
e7be50
+also skips any files whose size on the sending side gets shorter during
e7be50
+the send negotiations (rsync warns about a "diminished" file when this
e7be50
+happens). This does not interfere with the updating of a file\(cq\&s non\-content attributes
e7be50
 (e.g. permissions, ownership, etc.) when the file does not need to be
e7be50
 transferred, nor does it affect the updating of any non\-regular files.
e7be50
 Implies \fB\-\-inplace\fP.
e7be50
diff --git a/sender.c b/sender.c
e7be50
index 1cc28a1..e22eadd 100644
e7be50
--- a/sender.c
e7be50
+++ b/sender.c
e7be50
@@ -379,6 +379,16 @@ void send_files(int f_in, int f_out)
e7be50
 			}
e7be50
 		}
e7be50
 
e7be50
+		if (append_mode > 0 && st.st_size < F_LENGTH(file)) {
e7be50
+			rprintf(FWARNING, "skipped diminished file: %s\n",
e7be50
+				full_fname(fname));
e7be50
+			free_sums(s);
e7be50
+			close(fd);
e7be50
+			if (protocol_version >= 30)
e7be50
+				send_msg_int(MSG_NO_SEND, ndx);
e7be50
+			continue;
e7be50
+		}
e7be50
+
e7be50
 		if (st.st_size) {
e7be50
 			int32 read_size = MAX(s->blength * 3, MAX_MAP_SIZE);
e7be50
 			mbuf = map_file(fd, st.st_size, read_size, s->blength);