Reject any --remove-* options when read-only, just in case there
[rsync/rsync.git] / generator.c
index 7e3ba7f..13749f0 100644 (file)
@@ -829,7 +829,9 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                return;
        }
 
-       if (preserve_hard_links && hard_link_check(file, ndx, HL_CHECK_MASTER))
+       if (preserve_hard_links
+           && hard_link_check(file, ndx, fname, statret, &st,
+                              itemizing, code, HL_CHECK_MASTER))
                return;
 
        if (!S_ISREG(file->mode)) {
@@ -912,12 +914,14 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                                if (hard_link_one(file, ndx, fname, -1, &st,
                                                  fnamecmpbuf, 1,
                                                  itemizing && verbose > 1,
-                                                 code) == 0)
+                                                 code) == 0) {
+                                       if (preserve_hard_links
+                                           && file->link_u.links) {
+                                               hard_link_cluster(file, ndx,
+                                                                 itemizing,
+                                                                 code);
+                                       }
                                        return;
-                               if (verbose) {
-                                       rsyserr(FINFO, errno, "link %s => %s",
-                                               full_fname(fnamecmpbuf),
-                                               safe_fname(fname));
                                }
                                match_level = 2;
                        }
@@ -987,7 +991,9 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
        }
 
        if (statret != 0) {
-               if (preserve_hard_links && hard_link_check(file, ndx, HL_SKIP))
+               if (preserve_hard_links
+                   && hard_link_check(file, ndx, fname, statret, &st,
+                                      itemizing, code, HL_SKIP))
                        return;
                if (stat_errno == ENOENT)
                        goto notify_others;
@@ -1045,7 +1051,9 @@ prepare_to_open:
                        full_fname(fnamecmp));
            pretend_missing:
                /* pretend the file didn't exist */
-               if (preserve_hard_links && hard_link_check(file, ndx, HL_SKIP))
+               if (preserve_hard_links
+                   && hard_link_check(file, ndx, fname, statret, &st,
+                                      itemizing, code, HL_SKIP))
                        return;
                statret = real_ret = -1;
                goto notify_others;