X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/f8a94f0de88c5cbf24ef4d5a7d5cba1ead86afff..59c95e4243749273fe91f8197a39f89e4d905cb8:/generator.c diff --git a/generator.c b/generator.c index dd3eef66..f3849a07 100644 --- a/generator.c +++ b/generator.c @@ -41,6 +41,7 @@ extern int remote_version; extern int always_checksum; extern int modify_window; extern char *compare_dest; +extern int link_dest; /* choose whether to skip a particular file */ @@ -50,6 +51,15 @@ static int skip_file(char *fname, if (st->st_size != file->length) { return 0; } + if (link_dest) { + if((st->st_mode & ~_S_IFMT) != (file->mode & ~_S_IFMT)) { + return 0; + } + if (st->st_uid != file->uid || st->st_gid != file->gid) { + return 0; + } + } + /* if always checksum is set then we use the checksum instead of the file time to determine whether to sync */ @@ -356,6 +366,18 @@ void recv_generator(char *fname, struct file_list *flist, int i, int f_out) statret = -1; if (statret == -1) errno = saveerrno; +#if HAVE_LINK + else if (link_dest && !dry_run) { + if (do_link(fnamecmpbuf, fname) != 0) { + if (verbose > 0) + rprintf(FINFO,"link %s => %s : %s\n", + fnamecmpbuf, + fname, + strerror(errno)); + } + fnamecmp = fnamecmpbuf; + } +#endif else fnamecmp = fnamecmpbuf; }