Bug 420985 - KIO::mostLocalUrl shouldn't actually stat remote slaves
Summary: KIO::mostLocalUrl shouldn't actually stat remote slaves
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-04 07:57 UTC by Harald Sitter
Modified: 2020-05-25 07:38 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.71


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Sitter 2020-05-04 07:57:36 UTC
SUMMARY
Spun out of bug #420911

A remote slave is remote, it has no mostLocalUrl because it isn't local, so the stat is 100% of the time a waste of resources.
Therefore I believe KIO::mostLocalUrl should return a no-op statjob when the protocol isn't Class==:local
Comment 1 Ahmad Samir 2020-05-25 07:38:04 UTC
Git commit 38998e066aa711ec5da0d20817ff2f77d91b964b by Ahmad Samir.
Committed on 23/05/2020 at 15:46.
Pushed by dfaure into branch 'master'.

[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.

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.

M  +9    -0    autotests/jobtest.cpp
M  +1    -0    autotests/jobtest.h
M  +11   -8    src/core/statjob.cpp
M  +7    -5    src/core/statjob.h
M  +16   -0    src/ioslaves/trash/tests/testtrash.cpp
M  +1    -0    src/ioslaves/trash/tests/testtrash.h

https://invent.kde.org/frameworks/kio/commit/38998e066aa711ec5da0d20817ff2f77d91b964b