From 3bb88b4388478e3afdcdcd23df5880132a316d88 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Tue, 24 Apr 2007 17:53:54 +0000 Subject: [PATCH] Fixed a directory push problem with the user specified an arg with a subdir followed by an arg with no subdirs. --- flist.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/flist.c b/flist.c index eb94d004..8840eb86 100644 --- a/flist.c +++ b/flist.c @@ -1417,7 +1417,9 @@ void send_extra_file_list(int f, int at_least) struct file_list *send_file_list(int f, int argc, char *argv[]) { - int len; + static const char *lastdir; + static int lastdir_len = -1; + int len, dirlen; STRUCT_STAT st; char *p, *dir; char lastpath[MAXPATHLEN] = ""; @@ -1569,23 +1571,18 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) fn = "."; } - if (dir && *dir) { - static const char *lastdir; - static int lastdir_len = -1; - int len = strlen(dir); - - if (len != lastdir_len || memcmp(lastdir, dir, len) != 0) { - if (!push_flist_dir(strdup(dir), len)) - goto push_error; - lastdir = flist_dir; - lastdir_len = flist_dir_len; - } else if (!push_flist_dir(lastdir, lastdir_len)) { - push_error: - io_error |= IOERR_GENERAL; - rsyserr(FERROR, errno, "push_dir %s failed in %s", - full_fname(dir), curr_dir); - continue; - } + dirlen = dir ? strlen(dir) : 0; + if (dirlen != lastdir_len || memcmp(lastdir, dir, dirlen) != 0) { + if (!push_flist_dir(dir ? strdup(dir) : NULL, dirlen)) + goto push_error; + lastdir = flist_dir; + lastdir_len = flist_dir_len; + } else if (!push_flist_dir(lastdir, lastdir_len)) { + push_error: + io_error |= IOERR_GENERAL; + rsyserr(FERROR, errno, "push_dir %s failed in %s", + full_fname(dir), curr_dir); + continue; } if (fn != fbuf) -- 2.34.1