transfer logging -- absolute file path?

Wayne Davison wayned at samba.org
Tue Jun 13 17:57:55 GMT 2006


On Mon, Jun 12, 2006 at 09:37:43AM -0600, Alan Sparks wrote:
> I see in the code for the log_formatted() function the filename is
> special-cased if rsync is sending the file, but do not understand why
> this should be special-cased.

That's because only the sender has (or needs) path info from outside the
transfer.

> I did not want to use the pre-xfer exec, as it's too early (I need to run
> after the file is transferred successfully).

You misunderstood my suggestion.  I suggested adding a pre-xfer exec
that just logs the path info.  That would enable you to manually
post-process the log info using that extra logged information (or to
grab the info at the start of the post-xfer exec).

As for improving the %f escape, attached is a patch that prepends the
current directory when receiving a file.  This will add the missing
information on what file is being changed.  The patch may yet be
improved from this early state, but it looks good for now.

..wayne..
-------------- next part --------------
--- log.c	7 Jun 2006 23:05:17 -0000	1.155
+++ log.c	13 Jun 2006 17:54:42 -0000
@@ -49,6 +49,8 @@ extern char *logfile_name;
 #if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
 extern iconv_t ic_chck;
 #endif
+extern char curr_dir[];
+extern unsigned int module_dirlen;
 
 static int log_initialised;
 static int logfile_was_closed;
@@ -513,8 +515,18 @@ static void log_formatted(enum logcode c
 					strlcpy(n, buf2, MAXPATHLEN);
 				else
 					n = buf2;
-			} else
-				clean_fname(n, 0);
+			} else {
+				if (*n != '/') {
+					pathjoin(buf2, sizeof buf2,
+						 curr_dir + module_dirlen, n);
+					clean_fname(buf2, 0);
+					if (fmt[1])
+						strlcpy(n, buf2, MAXPATHLEN);
+					else
+						n = buf2;
+				} else
+					clean_fname(n, 0);
+			}
 			if (*n == '/')
 				n++;
 			break;


More information about the rsync mailing list