extern int read_batch;
extern int write_batch;
-static char topsrcname[MAXPATHLEN];
-
static struct exclude_struct **local_exclude_list;
static struct file_struct null_file;
if (l == -1)
return -1;
linkbuf[l] = 0;
- if (copy_unsafe_links && (topsrcname[0] != '\0') &&
- unsafe_symlink(linkbuf, topsrcname)) {
+ if (copy_unsafe_links && unsafe_symlink(linkbuf, path)) {
+ if (verbose > 1) {
+ rprintf(FINFO,"copying unsafe symlink \"%s\" -> \"%s\"\n",
+ path, linkbuf);
+ }
return do_stat(path, buffer);
}
}
if (readlink_stat(fname, &st, linkbuf) != 0) {
int save_errno = errno;
- if ((errno == ENOENT) && copy_links && !noexcludes) {
- /* symlink pointing nowhere, see if excluded */
+ if ((errno == ENOENT) && !noexcludes) {
+ /* either symlink pointing nowhere or file that
+ * was removed during rsync run; see if excluded
+ * before reporting an error */
memset((char *) &st, 0, sizeof(st));
if (check_exclude_file(f, fname, &st)) {
/* file is excluded anyway, ignore silently */
}
for (i = 0; i < argc; i++) {
- char *fname = topsrcname;
+ char fname2[MAXPATHLEN];
+ char *fname = fname2;
strlcpy(fname, argv[i], MAXPATHLEN);
}
}
- topsrcname[0] = '\0';
-
if (f != -1) {
send_file_entry(NULL, f, 0);
}
/*
* allocate a new file list
*/
-struct file_list *flist_new()
+struct file_list *flist_new(void)
{
struct file_list *flist;
static void clean_flist(struct file_list *flist, int strip_root)
{
int i;
+ char *name, *prev_name = NULL;
if (!flist || flist->count == 0)
return;
qsort(flist->files, flist->count,
sizeof(flist->files[0]), (int (*)()) file_compare);
- for (i = 1; i < flist->count; i++) {
- if (flist->files[i]->basename &&
- flist->files[i - 1]->basename &&
- strcmp(f_name(flist->files[i]),
- f_name(flist->files[i - 1])) == 0) {
- if (verbose > 1 && !am_server)
+ for (i = 0; i < flist->count; i++) {
+ if (flist->files[i]->basename) {
+ prev_name = f_name(flist->files[i]);
+ break;
+ }
+ }
+ while (++i < flist->count) {
+ if (!flist->files[i]->basename)
+ continue;
+ name = f_name(flist->files[i]);
+ if (strcmp(name, prev_name) == 0) {
+ if (verbose > 1 && !am_server) {
rprintf(FINFO,
"removing duplicate name %s from file list %d\n",
- f_name(flist->files[i - 1]),
- i - 1);
- /* it's not great that the flist knows the semantics of the
- * file memory usage, but i'd rather not add a flag byte
- * to that struct. XXX can i use a bit in the flags field? */
+ name, i);
+ }
+ /* it's not great that the flist knows the semantics of
+ * the file memory usage, but i'd rather not add a flag
+ * byte to that struct.
+ * XXX can i use a bit in the flags field? */
if (flist->string_area)
flist->files[i][0] = null_file;
else
free_file(flist->files[i]);
}
+ prev_name = name;
}
- /* FIXME: There is a bug here when filenames are repeated more
- * than once, because we don't handle freed files when doing
- * the comparison. */
-
if (strip_root) {
/* we need to strip off the root directory in the case
of relative paths, but this must be done _after_
}
}
-
if (verbose <= 3)
return;