Diffusion KIO 38998e066aa7

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

Authored by ahmadsamir on May 13 2020, 6:26 PM.

Description

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

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, and a new unit test that tests that mostLocalUrl for a local file was added
  • The testtrash unit test was extended to test mostLocalUrl (returns url as-is as the Trash protocol doesn't set UDS_LOCAL_PATH)

Reviewers: Frameworks, dfaure, sitter

Subscribers: kde-frameworks-devel

Tags: Frameworks

Differential Revision: https://phabricator.kde.org/D29782

Construct QUrl correctly with trash:/ protocol

Don't check the protocol class, checking if UDS_LOCAL_PATH is set is
enough.