Bug 463751

Summary: Cannot restore files sent to Trash via Qt because Dolphin incorrectly handles absolute paths for .trashinfo
Product: [Frameworks and Libraries] frameworks-kio Reporter: Patrick Silva <bugseforuns>
Component: TrashAssignee: David Faure <faure>
Status: RESOLVED FIXED    
Severity: normal CC: kdelibs-bugs, nate, nicolas.fella
Priority: NOR    
Version: 5.101.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 6.6
Sentry Crash Report:

Description Patrick Silva 2023-01-02 21:55:29 UTC
SUMMARY
A few days a bug was reported in the bug tracker of Strawberry player because it is impossible to restore audio files deleted with it. The Strawberry developer identified a bug with Dolphin:

"The paths being wrong is a KDE bug, while the character encoding issue is a Qt bug.
If you look at the trashinfo files in the .Trash-1000/info directory, you can see that those created by Qt are with absolute paths, but Dolphin incorrectly handles absolute paths for .trashinfo. Dolphin itself does not use Qt for moving files to trash, and uses relative paths, which is why it works for files deleted by Dolphin.
According to the specifications (https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html), it should be possible to use both.
You can also see by looking at the trashinfo files that the ones deleted using Qt is not URL encoded like they should.
I have submitted a fix to Qt for the encoding issue, and also proposed to change the paths to relative paths when possible: https://codereview.qt-project.org/c/qt/qtbase/+/450647"

link to Strawberry bug: https://github.com/strawberrymusicplayer/strawberry/issues/1086


EXPECTED RESULT
Dolphin should be able to restore files sent to Trash via Qt

SOFTWARE/OS VERSIONS
Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.26.80
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.7
Graphics Platform: Wayland
Comment 1 Bug Janitor Service 2023-01-10 01:28:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1106
Comment 2 Christoph Cullmann 2024-08-31 20:25:33 UTC
Git commit dd5428c95a69579887cad931e077802c770406c3 by Christoph Cullmann, on behalf of Nicolas Fella.
Committed on 31/08/2024 at 20:13.
Pushed by cullmann into branch 'master'.

[trash] Fix restoring entries with absolute paths in disk-local trash

If a mounted disk has a local trash folder we save a relative path to the mountpoint/trashdir in the trashinfo and restore accordingly.

However, an app writing to the trash might set an absolute path. Handle that properly

M  +4    -2    src/kioworkers/trash/trashimpl.cpp

https://invent.kde.org/frameworks/kio/-/commit/dd5428c95a69579887cad931e077802c770406c3