FIX: SFTP - preserve symlinks when copying to remote and syncing - #2919
Open
emilioheredia-source wants to merge 1 commit into
Open
emilioheredia-source wants to merge 1 commit into
emilioheredia-source wants to merge 1 commit into
Conversation
When copying a local directory tree to an SFTP destination, symlinks
were silently converted to regular files. Three layered bugs:
1. uwfxplugincopyinoperation.pas: the tree builder used fsooslFollow,
resolving symlinks to their targets before StoreFile was called.
2. uwfxpluginutil.pas / ProcessLink: no else-branch for the no-subnode
case (fsooslDontFollow), leaving Result uninitialised.
3. sftpsend.pas / StoreFile: opened local path with TFileStreamEx which
follows symlinks; never tried to create a remote symlink.
Fix - copy:
- sftpsend.pas: detect symlinks via fpLStat/fpReadLink before opening.
Unlink any existing destination, then call libssh2_sftp_symlink to
recreate the link on the remote (rsync-like behaviour). Falls back to
content upload if the server refuses. Unix-only ({ UNIX}).
- uwfxplugincopyinoperation.pas: switch SymLinkOption to fsooslDontFollow.
- uwfxpluginutil.pas / ProcessLink: add else-branch for the no-subnode
case, routing the symlink node to ProcessFile.
Fix - sync comparison:
- sftpsend.pas / FsFindNextW: save the symlink's own attributes before
following the link target to detect directories; restore mtime, atime
and filesize afterwards (symlink filesize = byte length of target string).
- fsyncdirsdlg.pas / AreEquivalentLinks: when one side does not expose
the link target (e.g. WFX/SFTP plugin), fall back to size comparison.
- fsyncdirsdlg.pas / UpdateState: let AreEquivalentLinks override the
timestamp gate so symlinks compare as equal regardless of mtime.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When copying a local directory tree to an SFTP destination, symlinks were silently converted to regular files. Three layered bugs:
uwfxplugincopyinoperation.pas: the tree builder used fsooslFollow, resolving symlinks to their targets before StoreFile was called.
uwfxpluginutil.pas / ProcessLink: no else-branch for the no-subnode case (fsooslDontFollow), leaving Result uninitialised.
sftpsend.pas / StoreFile: opened local path with TFileStreamEx which follows symlinks; never tried to create a remote symlink.
Fix - copy:
Fix - sync comparison:
End result:
After this fix, it is possible to copy a local directory tree to a remote Linux host over SFTP and use the folder sync tool to verify that the remote is an exact clone of the source — symlinks included. This covers a common workflow (backup, deployment, mirroring) that previously required falling back to rsync or similar command-line tools, and replaces it with a native GUI operation inside Double Commander.