bsync icon indicating copy to clipboard operation
bsync copied to clipboard

Symlinks aren't followed

Open IslandC0der opened this issue 4 years ago • 4 comments

I have a directory with a lot of symlinks (both files and dirs), and, when I sync it, the expected behavior would be for the actual file or directory to be synced, not the symlink itself. rsync has the -L flag which does exactly this, so I hope this wouldn't be too hard to implement: In the same way that bsync has the -o flag to pass arguments to ssh, I propose for there to be a similar flag that allows us to pass custom arguments to rsync. However, this would require some further changes: for instance, to the code that generates the .bsync-snap to account for when we want to follow symlinks (pass the -L flag to find). However, I also had to edit the flags that are currently passed to rsync by default, namely -a which conflicts with -L. According to man rsync, -a is the same as -rlptgoD, so I just changed -a to -rLptgoD to test, and the rsync part worked.

IslandC0der avatar Apr 17 '20 11:04 IslandC0der

Thanks for your feedbak/idea.

There are more things to consider:

  • how do we handle circular symlinks
  • do we need additionnal checks when symlinks to another filesystem type (permissions/modification date) may be different.

I would be glad to test if you have a working patched version.

dooblem avatar Apr 21 '20 12:04 dooblem

Done, just sent a pull request. It would be nice to maybe add it as an option instead of hard-coding it. That said, I can't think of many cases where you'd want to copy the symlink itself instead of the file it actually points to, but let me know what you think.

IslandC0der avatar Apr 21 '20 17:04 IslandC0der

Also, regarding circular symlinks: find already detects them, and it will output an error, which will cause bsync to abort due to a "Find error".

IslandC0der avatar Apr 21 '20 18:04 IslandC0der

Hi, please also consider that current behaviour is in most case more relevant ie. in my case I save the .wine directory witch have a sub-directory "game" that is a link to a directory on a SSD I don't want this simlink to be transformed to a regular directory or it content to be copied I rather have to issue 2 bsync command : 1 for .wine and 1 for the directory "game" on the SSD witch is exactly the current behaviour

sdelanoue avatar Aug 14 '20 22:08 sdelanoue