[KPropertiesDialog] Disable changing remote dir icons
ClosedPublic

Authored by ahmadsamir on Apr 8 2020, 1:25 PM.

Details

Summary

Changing the icon of a dir on e.g. a samba share doesn't seem to have
an effect, this is intentional as reading .directory would impact network
resources negatively, see the bug report for more details. Change the code
to only show the KIconButton only for local dirs and desktop:/.

BUG: 205954

Test Plan

make && ctest
And testing an sftp://, the button to change the icon isn't shown

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.Apr 8 2020, 1:25 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptApr 8 2020, 1:26 PM
ahmadsamir requested review of this revision.Apr 8 2020, 1:26 PM

I don't have access to a samba share so I tested with an sftp:// one, after modifying the diff locally.

sitter added a comment.Apr 8 2020, 1:44 PM

Looks reasonable. Though... Shouldn't that rather be any protocol that isn't file? Or at least all that are remote? (assuming we have a way of telling which slaves are remote)

If I open sftp it also shows no dir icons yet lets me set one.

broulik added a subscriber: broulik.EditedApr 8 2020, 1:47 PM

assuming we have a way of telling which slaves are remote

KProtocolInfo::protocolClass(url.scheme()) not being ":local"
though maybe we want to follow the isSlow thing KFileItemuses? Since it doesn't flat out disable icons but just on certain known slow (smb, cifs, etc)

I thought about that, but since I am not experienced with network mounts (I rarely use them), I didn't expand the test

Looks reasonable. Though... Shouldn't that rather be any protocol that isn't file? Or at least all that are remote? (assuming we have a way of telling which slaves are remote)

If I open sftp it also shows no dir icons yet lets me set one.

I thought about that, but since I am not experienced with network mounts (I rarely use them), I didn't venture that way.

About checking, KFileItem has an isLocalFile() method.

ahmadsamir updated this revision to Diff 79643.Apr 8 2020, 1:54 PM

--verbatim

sitter added a comment.Apr 8 2020, 2:20 PM

Hm. So, this is a bit complicated I've noticed.

Let's consider the following cases:

  • desktop: is not a local file but can set and read dir icons without penalty
  • camera: is not a local file AND Class=:local BUT (I think?) cannot set dir icons as it is writing=false (in practice the slave seems to list dirs with rwx though, so I'm not sure, may be a slave bug)
  • smb: is not a local file AND not local class nor do we want to have icons for it

With that in mind I believe Kai's approach would be more correct here as otherwise the desktop: case doesn't work. Perhaps it'd make also sense to check !KProtocolInfo::supportsWriting. The way I see it if a slave implementation doesn't support writing... then it doesn't support writing. The directory being writable or not wouldn't change the lack of write support in the slave.

ahmadsamir planned changes to this revision.Apr 8 2020, 2:33 PM

OK, thanks for the pointers.

I did some more testing:

$ grep -ir :local *protocol
about.protocol:Class=:local
activities.protocol:Class=:local
applications.protocol:Class=:local
ar.protocol:Class=:local
baloosearch.protocol:Class=:local
bookmarks.protocol:Class=:local
camera.protocol:Class=:local
desktop.protocol:Class=:local
filenamesearch.protocol:Class=:local
fonts.protocol:Class=:local
info.protocol:Class=:local
man.protocol:Class=:local
programs.protocol:Class=:local
recentdocuments.protocol:Class=:local
settings.protocol:Class=:local
tags.protocol:Class=:local
tar.protocol:Class=:local
timeline.protocol:Class=:local
zip.protocol:Class=:local
$ grep -ir writ *protocol
activities.protocol:writing=true
applications.protocol:writing=false
baloosearch.protocol:writing=false
camera.protocol:writing=false
cifs.protocol:writing=true
desktop.protocol:writing=true
filenamesearch.protocol:writing=false
fish.protocol:writing=true
fonts.protocol:writing=true
ldap.protocol:writing=true
ldaps.protocol:writing=true
metainfo.protocol:writing=true
mmst.protocol:writing=false
mmsu.protocol:writing=false
mtp.protocol:writing=true
pnm.protocol:writing=false
programs.protocol:writing=false
recentdocuments.protocol:writing=true
rtsp.protocol:writing=false
rtspt.protocol:writing=false
rtspu.protocol:writing=false
settings.protocol:writing=false
sftp.protocol:writing=true
smb.protocol:writing=true
tags.protocol:writing=true
timeline.protocol:writing=true

from all these, I would enable changing icon for KItemFile.isLocalFile(), desktop:/ and recentdocuments:/; I couldn't test the camera:/ protocol as I don't currently have access to a camera.

And it seems recentdocuments:/ shows representation of recent "documents", parsed from .desktop files in ~/.local/share/RecentDocuments/, so it doesn't need to be handled here.

ahmadsamir updated this revision to Diff 79766.Apr 10 2020, 2:36 PM
ahmadsamir retitled this revision from [KPropertiesDialog] Disable changing dir icon on samba shares to [KPropertiesDialog] Disable changing remote dir icons.
ahmadsamir edited the summary of this revision. (Show Details)
ahmadsamir edited the test plan for this revision. (Show Details)
ahmadsamir removed a subscriber: broulik.

Exclude everything that's !isLocalFile() or desktop:/

dfaure accepted this revision.Apr 11 2020, 8:44 AM
dfaure added inline comments.
src/widgets/kpropertiesdialog.cpp
1285

missing space before ||

This revision is now accepted and ready to land.Apr 11 2020, 8:44 AM
ahmadsamir updated this revision to Diff 79814.Apr 11 2020, 9:33 AM

Rebase; fix coding style

This revision was automatically updated to reflect the committed changes.