Make it possible to go up to root again
ClosedPublic

Authored by jtamate on Jun 22 2018, 9:32 AM.

Details

Summary

If u == "file:///", then u.setPath(u.path() + '/') results in u == "".
Avoid making this transformation for all schemes (thanks @dfaure).

Test Plan

In a File open dialog, go to a nfts disk root, that results in currentUrl = file:///d//
Before, when I pressed the upCd dir (^) I was redirected to my home directory, after I see the root directory.

Diff Detail

Repository
R241 KIO
Lint
Lint Skipped
Unit
Unit Tests Skipped
jtamate created this revision.Jun 22 2018, 9:32 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptJun 22 2018, 9:32 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
jtamate requested review of this revision.Jun 22 2018, 9:32 AM
dfaure requested changes to this revision.Jun 22 2018, 9:54 AM
dfaure added inline comments.
src/filewidgets/kfilewidget.cpp
1547 ↗(On Diff #36499)

Shouldn't this be generalized to all schemes? I.e.

if (!u.path().isEmpty() && u.path() != "/")

We don't want to turn smb:/// into smb:////.

But wait, we also simply don't want to append a slash if there was already one.
The comment says "if needed", the code doesn't check for that.

New suggestion:

if (!u.path().isEmpty() && !u.path().endsWith('/'))
This revision now requires changes to proceed.Jun 22 2018, 9:54 AM
jtamate updated this revision to Diff 36504.Jun 22 2018, 10:20 AM
jtamate marked an inline comment as done.
jtamate edited the summary of this revision. (Show Details)

Your suggested code works.

aacid added a subscriber: aacid.Jun 22 2018, 10:22 AM

Can this be auto tested?

dfaure requested changes to this revision.Jun 22 2018, 10:36 AM
dfaure added inline comments.
src/filewidgets/kfilewidget.cpp
1543

I think this comment only adds more confusion, because the code doesn't show "" anywhere, it's a side effect of creating an invalid url (or something, I actually wonder why file://// would be invalid...)

IMHO it's clear without the added comment. "append slash if needed", and then the if checks if there's already a trailing slash.

This revision now requires changes to proceed.Jun 22 2018, 10:36 AM
jtamate updated this revision to Diff 36533.Jun 22 2018, 6:29 PM
jtamate marked an inline comment as done.

Removed comment and added autotest.

Thanks!

autotests/kfilewidgettest.cpp
226 ↗(On Diff #36533)

This comment should move to line 220, since it matches that specific row of test data ;)

jtamate updated this revision to Diff 36534.Jun 22 2018, 6:45 PM

Moved the comment.

dfaure accepted this revision.Jun 24 2018, 12:10 PM
This revision is now accepted and ready to land.Jun 24 2018, 12:10 PM
This revision was automatically updated to reflect the committed changes.

The unittest fails in CI, please take a look.

https://build.kde.org/view/Frameworks/job/Frameworks%20kio%20kf5-qt5%20SUSEQt5.10/313/testReport/(root)/TestSuite/kiofilewidgets_kfilewidgettest/

When I tried running the test locally, I got a prompt from sftp about verifying the identity of 127.0.0.1 .... not great for a unittest, to ask for user input.
This also means the test is dependent on kio_sftp being installed? That's no good, it's not part of KIO, so it's not available for CI.

Please use a URL that is sure to work (maybe FTP on a public site), or better, somehow stub out any actual kioslave usage, and *just* test URLs.

somehow stub out any actual kioslave usage, and *just* test URLs.

Please, check https://phabricator.kde.org/D13939