- if (head_file->F_HLINDEX == FINISHED_LINK) {
- STRUCT_STAT st2, st3;
- char *toname = f_name(head_file);
- if (link_stat(toname, &st2, 0) < 0) {
- rsyserr(FERROR, errno, "stat %s failed",
- full_fname(toname));
- return -1;
+ return 0;
+ }
+
+ /* There is a finished file to link with! */
+ if (!(prev_file->flags & FLAG_HLINK_FIRST)) {
+ /* The previous previous will be marked with FIRST. */
+ prev_ndx = F_HL_PREV(prev_file);
+ prev_file = cur_flist->files[prev_ndx];
+ /* Update our previous pointer to point to the first. */
+ F_HL_PREV(file) = prev_ndx;
+ }
+ alt_dest = F_HL_PREV(prev_file); /* alternate value when DONE && FIRST */
+ if (alt_dest >= 0 && dry_run) {
+ pathjoin(prev_name, MAXPATHLEN, basis_dir[alt_dest],
+ f_name(prev_file, NULL));
+ f_name(prev_file, altbuf);
+ realname = altbuf;
+ } else {
+ f_name(prev_file, prev_name);
+ realname = prev_name;
+ }
+
+ if (link_stat(prev_name, &prev_st, 0) < 0) {
+ rsyserr(FERROR, errno, "stat %s failed",
+ full_fname(prev_name));
+ return -1;
+ }
+
+ if (statret < 0 && basis_dir[0] != NULL) {
+ /* If we match an alt-dest item, we don't output this as a change. */
+ char cmpbuf[MAXPATHLEN];
+ statx alt_sx;
+ int j = 0;
+#ifdef SUPPORT_ACLS
+ alt_sx.acc_acl = alt_sx.def_acl = NULL;
+#endif
+ do {
+ pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
+ if (link_stat(cmpbuf, &alt_sx.st, 0) < 0)
+ continue;
+ if (link_dest) {
+ if (prev_st.st_dev != alt_sx.st.st_dev
+ || prev_st.st_ino != alt_sx.st.st_ino)
+ continue;
+ statret = 1;
+ if (verbose < 2 || !stdout_format_has_i) {
+ itemizing = 0;
+ code = FNONE;
+ if (verbose > 1 && maybe_ATTRS_REPORT)
+ rprintf(FCLIENT, "%s is uptodate\n", fname);
+ }
+ break;