Bug 352927

Summary: Copying symbolic links with Dolphin adds absolute path to link
Product: [Frameworks and Libraries] frameworks-kio Reporter: Uri Herrera <uri_herrera>
Component: generalAssignee: David Faure <faure>
Status: RESOLVED FIXED    
Severity: major CC: frank78ac, kdelibs-bugs, simonandric5, varlesh
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 5.16

Description Uri Herrera 2015-09-20 00:06:22 UTC
Dolphin doesn't seem to respect the relative paths on symbolic links. Whenever I create a symbolic link with the command ln -s (I don't use the context menu) and then copy this link to the desired folder the link while working contains the absolute path of the target file.

Where the link should be:
target: ../../../file

It actually is:

target: /home/$user/folder/file

Reproducible: Always

Steps to Reproduce:
1. Create a file
2. Create a link with ln -s
3. Copy with Ctrl+C and paste with Ctrl+V

Actual Results:  
Link copied contains absolute path of the target file.

Expected Results:  
Link should have the relative path of the target file.

This happens with PCManFM Qt too but not the GTK version. This behavior didn't happen in previous versions of Dolphin (like 4.14.x) either.
Comment 1 Frank Reininghaus 2015-09-20 07:56:40 UTC
Thanks for the bug report. I can confirm this behavior. I cannot comment on whether this change is intended or not.

I assume that this could be due to a change in the KIO library, which Dolphin and other KDE applications use for copying files.
Comment 2 David Faure 2015-10-04 08:53:36 UTC
Indeed this didn't happen in the kdelibs4 version of Dolphin.
Comment 3 David Faure 2015-10-04 09:13:28 UTC
Nice, QFileInfo::symlinkTarget() always returns an absolute path, and there's no function in Qt for reading the relative symlink target. I'll use readlink....
Comment 4 David Faure 2015-10-04 09:24:10 UTC
https://git.reviewboard.kde.org/r/125515/
Comment 5 David Faure 2015-10-24 18:02:26 UTC
Git commit f2c96d1550f22600f1b6dee74851c25a3f733ef4 by David Faure.
Committed on 24/10/2015 at 18:01.
Pushed by dfaure into branch 'master'.

Preserve relative link targets when copying symlinks.
REVIEW: 125515
FIXED-IN: 5.16
Change-Id: I7d3c988da32cae9d14750c8adb9ca5af6d140572

M  +59   -0    autotests/jobtest.cpp
M  +2    -0    autotests/jobtest.h
M  +12   -1    src/ioslaves/file/file.cpp

http://commits.kde.org/kio/f2c96d1550f22600f1b6dee74851c25a3f733ef4
Comment 6 varlesh 2016-07-10 14:28:10 UTC
Why on Dolphin bugged symlinks???
I create symlink New - Symbolic Link
Link: Folder2
Path: ../../Folder
Open preferncies  Folder2 and see link:
 /home/user/folder/.../.../folder
What is this?
Why not save real name ../../folder?
Comment 7 David Faure 2016-07-14 14:38:30 UTC
varlesh: please open new bug reports for unrelated problems. This bug report was about *copying* symlinks, your report is about *creating* symlinks. I can confirm the bug and I'm looking into it, but please don't hijack existing bug reports for new issues. Can you open a new bug report?