Repository navigation
generator: preserve newer destination symlinks with --update-links - #198
Conversation
|
The test included in the PR needs further work to run on FreeBSD apparently. |
|
I'll note that tweaking |
Noted and added it in commit |
| { | ||
| #ifdef SUPPORT_LINKS | ||
| if (copy_links) | ||
| if (copy_links && update_links == 0) |
There was a problem hiding this comment.
If they asked for --copy-links they should get --copy-links. Remember that it's only the sending side that sees this flag set, not the receiving side, so combining --copy-links with --update-links would mean that the sender doesn't send any symlinks, and the receiver could deal with any existing symlinks in the destination using the new option. (Thus, drop this change.)
There was a problem hiding this comment.
These two modes appear mutually exclusive from a user standpoint. Either every symlink is transformed into referent (--copy-links) or copied across if newer (--update-links).
so combining --copy-links with --update-links would mean that the sender doesn't send any symlink
From testing the PR'd code briefly now, when both modes are enabled, --update-links trumps --copy-links, by virtue of a subsequent condition at if (update_links && S_ISLNK(stp->st_mode)).
Added #274 to discuss how to handle symlink mode precedence.
| STRUCT_STAT st; | ||
| if (x_stat(path, &st, NULL) == 0 && !S_ISDIR(st.st_mode)) | ||
| return x_lstat(path, stp, NULL); | ||
| } |
There was a problem hiding this comment.
This hunk baffles me. It does a stat of the referent file, and if it's a non-dir it re-stats the symlink's stat that is already present in stp and returns. But if it is not a dir, the following code also returns the same stat data that is already in stp. So, it seems like this can be dropped as well.
There was a problem hiding this comment.
Precisely, if the symlink points at a non-directory referent, return the symlink's stat or fall through. It's only apparent looking at the surrounding code why the x_lstat call is redundant. Committed as aed6235, works on assumption lstat or lstat64 is guaranteed to return either 0 or -1 on all platforms.
41ccee5 to
17c7806
Compare
6b54077 to
af4de04
Compare
df08e29 to
1dc68a2
Compare
b42230f to
7ba3169
Compare
7ba3169 to
aff59bb
Compare
This reverts commit c3437c1, the redundant macro call is intended to avoid running the macro if neither update_links nor follow_dirlinks are enabled.
aff59bb to
8bac01f
Compare
This PR enhances rsync with an independent update mode for symbolic links. Its main purpose is to skip symlinks that are newer on the receiver. The mode is enabled independently of the update mode via the
--update-linksswitch. To extend the behaviour of this option to empty directories, an additional--allow-link-update-dirswitch may be enabled. In this mode, a less recent empty directory on the destination may be replaced with a more recent symbolic link from the source.The PR includes a sanity test to verify the impact of the proposed modes on a set of files (relative, dangling, absolute, unsafe, devlink dirlink, empty directory, non-empty directory, fifo) under different circumstances.