lib/scanner: Add option to follow symlinks#3387
lib/scanner: Add option to follow symlinks#3387calmh wants to merge 1 commit intosyncthing:masterfrom calmh:fix-1776
Conversation
This adds the ability to follow some symlinks when scanning. Symlinks to files are not supported. We could support this on the scanner side, it's not super difficult, but it's a little bit more involved on the puller side. At the moment I think that's less important so I'm leaving it for the future.
|
The ❌ for Windows in the test results tells me that there may be some adjustment needed there... |
| goto ok | ||
| } | ||
| } | ||
| continue nextSymlink |
There was a problem hiding this comment.
Don't understand this whole magic.
I think the FollowSymlinks should be existing symlinks that are relative to the folder root.
There was a problem hiding this comment.
It is. But we need to call Walk() on it, which we can't cleanly do inside the walkFn
|
OK I might as well implement it for files as well if it's worth doing at all. |
|
Other notable restrictions would be that
|
|
In principle, this is going in the right direction, but frankly, it's a disaster from a users POV. With your approach I might end up with say 100 symlinks in the config. Not funny. From the user POV, the better logic would be a boolean per folder: if true, follow them, or not otherwise. Versioning is not compatible of course, and it might even be a good idea to handle this folder read only (from syncthing perspective). |
|
@frispete a per folder option sounds like a natural thing to do |

This is a tech preview, not done yet, not for merging. Specifically there is no UI. For discussion to see if I'm along the right path.
Purpose
This adds the ability to follow some symlinks when scanning.
The principle is that the symlinks to follow must be explicitly named in the config - those, and only those, are followed.
Only symlinks to directories are supported - not symlinks to files. We could support that on the scanner side, it's not super difficult, but it's a little bit more involved on the puller side as we don't want to replace the symlink when pulling and we need to create the temp files on the other side of the symlink etc. At the moment I think that's less important so I'm leaving it for the future.
Testing
Unit tested on the scanner side... Puller side should be fine, it should just go through the symlink. No idea how well any of this works on Windows...