Topic "Warn when duplicating remote symlinks?"

Author Message
ekorn
[View user's profile]

Joined: 2009-01-07
Posts: 3
I'm very grateful for the existence of WinSCP 8-)

However, today I got burned trying to backup a symlinked file via "Duplicate" (from the remote file's context menu). I expected this to work like a Linux command-line "cp", which copies the contents of the symlink's target into a new file by default. It seems "Duplicate" works like cp --no-dereference, just making another symlink. Thus, changes to the duplicate affect the original file. So now I have no backup and two symlinks to a broken revision 8-P

I suggest that "Duplicate" offer an option whether to copy symlinks as symlinks, or at least a warning that this may not be what the user expects. (Copying a shortcut on Windows will copy the shortcut, so I it's not obvious what the default should be. However, I think I'm not alone in viewing Duplicate as synonymous with "cp".)
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
What protocol? What mode of duplication have you used? Direct or via local temporary copy?
_________________
Martin Prikryl
ekorn
[View user's profile]

Joined: 2009-01-07
Posts: 3
prikryl wrote:
What protocol?


SFTP (protocol 2, according to the saved settings).

prikryl wrote:
What mode of duplication have you used? Direct or via local temporary copy?


Direct; I see that it's fast even for large files. (WinSCP automatically starts another session to perform the command, if I understand correctly.)
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
In that case WinSCP does "cp -p -r -f". What would you suggest instead?
_________________
Martin Prikryl
ekorn
[View user's profile]

Joined: 2009-01-07
Posts: 3
prikryl wrote:
In that case WinSCP does "cp -p -r -f". What would you suggest instead?


Thanks for the specifics. After some testing and googling, I found some details on the cp -r option:

Quote:
By default, cp follows symbolic links only when not copying recursively. This default can be overridden with the --archive (-a), -d, --dereference (-L), --no-dereference (-P), and -H options. If more than one of these options is specified, the last one silently overrides the others.

By default, cp copies the contents of special files only when not copying recursively. This default can be overridden with the --copy-contents option.


So, for instance:

Code:

$ touch target.txt                                          # make a file
$ ln -s target.txt symlink_to_target.txt                    # symlink to it
$ cp symlink_to_target.txt cp_of_symlink_to_target.txt      # cp copies target
$ cp -r symlink_to_target.txt cp_r_of_symlink_to_target.txt # cp -r copies symlink
$ ls -l
-rw-r--r--  1 ...  0 Jan 12 13:39 cp_of_symlink_to_target.txt
lrwxrwxrwx  1 ... 10 Jan 12 13:41 cp_r_of_symlink_to_target.txt -> target.txt
lrwxrwxrwx  1 ... 10 Jan 12 13:39 symlink_to_target.txt -> target.txt
-rw-r--r--  1 ...  0 Jan 12 13:38 target.txt


I would suggest a warning prompt asking how to copy symlinks (with the usual "Do not show this message again" option to minimize the inconvenience). The decision might amount to setting one of the -adLPH options mentioned above, but I'm not familiar enough with them to know which one to use.

(Alternatively, the -r option might be omitted if the selection being Duplicate'd does not contain any directories. However, I suspect this would be at least as confusing as the current implementation.)

Thank you very much for your help.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
This request has been added to tracker.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License