[StatJob] Make mostLocalUrl ignore remote (ftp, http...etc) URLs
ClosedPublic

Authored by ahmadsamir on May 15 2020, 4:05 PM.

Details

Summary

Previously mostLocalUrl would check that !url.isLocalFile(), that meant
a statjob would be fired for remote urls (ftp, http... etc), such urls
will never have a mostLocalUrl. Instead check for protocols with Class=:local.

Also if the statjob is created via KIO::mostLocalUrl, the job was, correctly,
cancelled if the url isLocalFile(), extend it to also cancel the job if the
protocol Class isn't ":local".

For a list of such protocols: grep :local /usr/share/kservices5/*.protocol

Thanks to sitter for figuring it out in the bug report.

BUG: 420985
FIXED-IN: 5.71

Test Plan

the jobtest unit test still passes

Diff Detail

Repository
R241 KIO
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ahmadsamir created this revision.May 15 2020, 4:05 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 15 2020, 4:05 PM
ahmadsamir requested review of this revision.May 15 2020, 4:05 PM
ahmadsamir planned changes to this revision.May 15 2020, 5:17 PM
ahmadsamir updated this revision to Diff 82974.May 15 2020, 7:36 PM
ahmadsamir retitled this revision from [StatJob] Change mostLocalUrl to only handle protocols with Class=:local to [StatJob] Make mostLocalUrl ignore remote (ftp, http...etc) URLs.
ahmadsamir edited the summary of this revision. (Show Details)
ahmadsamir edited the test plan for this revision. (Show Details)

Improve

Can you add a unittest for a KIO::mostLocalUrl() in testtrash.cpp (which is :local, so it should work)
and another one in jobtest.cpp for a http URL (e.g. to test which error code we're getting, if any?)

+ call mostLocalUrl() on a "normal" StatJob in testtrash.cpp

Thanks.

Can you add a unittest for a KIO::mostLocalUrl() in testtrash.cpp (which is :local, so it should work)

I don't see where the trash ioslave sets UDS_LOCAL_PATH; I think it doesn't set it, I could be wrong, though.

and another one in jobtest.cpp for a http URL (e.g. to test which error code we're getting, if any?)

I'll look into that next.

+ call mostLocalUrl() on a "normal" StatJob in testtrash.cpp

Same as the first point :)

[...]

I've just realised, we won't get an error with an http url; in that case we return the url the statjob was called on as-is and cancel the job.

OK, I picked testtrash because kio_trash *is* a :local protocol. If it doesn't use UDS_LOCAL_PATH, at least it means the job will actually go through (no early filtering out). That's at least interesting to test too.

Good that http will give no error. That's something else the test can check :-)

kio_remote is part of kio and sets UDS_LOCAL_PATH, maybe it can be used for testing the case where we'll actually find a local path. I'm afraid there isn't much testing of that kioslave though, so this sounds like a bigger effort.

This revision was not accepted when it landed; it landed in state Needs Review.May 23 2020, 12:52 PM
This revision was automatically updated to reflect the committed changes.

This wasn't landed on master, but rather phabricator is confused by me pushing to work/ branch on gitlab :)