Bug 382341 - Target Url not updated after renaming a desktop file in folder mode
Summary: Target Url not updated after renaming a desktop file in folder mode
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.36.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
: 382730 383996 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-07-14 13:20 UTC by Gabriel C
Modified: 2022-04-11 12:05 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.37


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gabriel C 2017-07-14 13:20:23 UTC
This was noticed by kbroulik.


after commit/6ca0b93e6029dc53a09e9e498e509ba714c2a1d7
( Use KIO::rename instead of KIO::moveAs in setData )

renaming a file will work but when trying to launch it it gives an error about
oldUrl cannot be found.

Restarting palsmashell seems to fix that.

Simple reproducer:

Add dolphin to desktop
Rename it to dolphin2
Click on the renamed icon 
You should get an error

Restart plasmashell and all is fine again
Comment 1 Kai Uwe Broulik 2017-07-14 13:25:20 UTC
Only affects desktop:/ KIO slave in FolderView. When FV is set to e.g. /home/foo it works.
Comment 2 Kai Uwe Broulik 2017-07-14 13:26:15 UTC
Might be a bug in the desktop KIO that sets UDS_TARGET_URL to LOCAL_PATH for some reason.
Comment 3 Kai Uwe Broulik 2017-07-14 13:27:55 UTC
In KCoreDirListerCache::slotFileRenamed it updates KFileItem's localPath if "dstPath" is provided (which it is by emitFileRenamedWithLocalPath) but it cannot know that desktop KIO sets the target URL to it, so it gets out of sync.
Comment 4 David Faure 2017-07-21 17:09:40 UTC
Confirmed; thanks for the debugging.

The thing is, shortly after KCoreDirLister::slotFileRenamed is called, desktopnotifier also triggers a full re-listing via KDirNotify::FilesAdded which calls KCoreDirLister::updateDirectory. That's when the dirlister should notice that the target URL of the item has changed.
But it failed to do so because KFileItem::cmp() ignores UDS_LOCAL_PATH and UDS_TARGET_URL. Adding that fixes the bug.
I'll work on a unittest and then commit that.
Comment 5 David Faure 2017-07-22 06:52:30 UTC
Git commit 1449ecf136b5d170cb7c66e62a302bb9e9df164b by David Faure.
Committed on 22/07/2017 at 06:52.
Pushed by dfaure into branch 'master'.

Ensure KDirLister updates items whose target URL has changed.

This fixes the bug where renaming a desktop icon would not update
its target URL, so clicking on it would try to open the old file.

The tricky bit in all this is that first KCoreDirLister::slotFileRenamed
is called, which updates the item's name (and local path), but then
later on desktopnotifier also triggers a full re-listing via
KDirNotify::FilesAdded which calls KCoreDirLister::updateDirectory.
That's when the dirlister should notice that the target URL of the item
has changed.

For consistency, also compare local paths, although this commit doesn't
actually require it.

Unittest improved in plasma-workspace/kioslave/desktop/tests.
FIXED-IN: 5.37

M  +2    -0    src/core/kfileitem.cpp

https://commits.kde.org/kio/1449ecf136b5d170cb7c66e62a302bb9e9df164b
Comment 6 Kai Uwe Broulik 2017-07-25 20:31:52 UTC
*** Bug 382730 has been marked as a duplicate of this bug. ***
Comment 7 David Faure 2017-07-28 10:01:35 UTC
Git commit 31bbfe5987698d39e806087e559e74b5fab70ed6 by David Faure.
Committed on 28/07/2017 at 10:01.
Pushed by dfaure into branch 'Plasma/5.10'.

Improve unittest for renaming desktop icons

to ensure that the target URL is updated by KDirLister.
This unittest requires the KIO fix 1449ecf136 (KF 5.37).

The unittest detected a "//" in the UDS_LOCAL_PATH values,
so this commit fixed that as well.

M  +9    -1    kioslave/desktop/kio_desktop.cpp
M  +1    -1    kioslave/desktop/tests/CMakeLists.txt
M  +36   -19   kioslave/desktop/tests/kio_desktop_test.cpp

https://commits.kde.org/plasma-workspace/31bbfe5987698d39e806087e559e74b5fab70ed6
Comment 8 Kai Uwe Broulik 2017-08-25 08:44:55 UTC
*** Bug 383996 has been marked as a duplicate of this bug. ***
Comment 9 Fushan Wen 2022-04-11 12:05:46 UTC
The test continues failing. Should it be dropped?