When dragging a file from one desktop:/ to another desktop:/ KIO wouldn't notice it's the same location as the source would be
file:///home/foo/Desktop//bar
whereas the destination is
file:///home/foo/Desktop/./bar
This patch strips those unneccessary intermediate path segments.
Details
I was surprised that KIO/KFileItem/UDSEntry wasn't smarter here and this patch is probably wrong on many levels.. :)
Diff Detail
- Repository
- R120 Plasma Workspace
- Lint
Lint Skipped - Unit
Unit Tests Skipped
QDir::cleanPath or QUrl::NormalizePathSegments can help making this fix more generic.
But I'm curious, where does the "/." come from in the first place?
I don't know. The rewritten url for desktop:/ is clean (/home/foo/Desktop) but in KFileItem I see tons of places that are like path + '/' + name but I haven't figured out where the "." actuall comes from...
It's look like relative path to me. If i'm not wrong KFileItem::setLocalPath should resolve relative path ?
For some reason the UDS_LOCAL_PATH isn't properly filled, KFileItem localPath() is still desktop:/ but I got lost in KIO code trying to figure it out :(
This also results in bad side-effects like the "Move To Trash" option not being available, just "Delete"
KFileItem::localPath() should not ever ever be a URL like desktop:/. That would be very wrong.
It just returns what you set in UDS_LOCAL_PATH, so it's kio_desktop you should debug, not kio ;)
Well except for KIO::ForwardingSlaveBase, called by kio_desktop -- note that ForwardingSlaveBase::prepareUDSEntry already sets UDS_LOCAL_PATH, but ok you call insert again which replaces that value.
The code looks ok to me, are you 100% sure about your diagnostic that localPath() returns desktop:/... ?
Taking for example the context menu code in FolderView:
It does KFileItem = m_dirModel->itemForIndex(index);
item.localPath(): ""
item.isLocalFile(): false
item.mostLocalUrl(): QUrl("desktop:/foo")
item.targetUrl(): QUrl("desktop:/foo")
item.entry().stringValue(KIO::UDSEntry::UDS_LOCAL_PATH): ""
If you right click an item in desktop:/ the "Move to Trash" option will not be available, both in FolderView and Dolphin because it doesn't consider it a local file.
Somehow I must have screwed up my setup somehow, I can't reproduce the issues I had anymore and never had it on my laptop to begin with.