Skip mime type check only for files on network mounts
Needs ReviewPublic

Authored by meven on Aug 16 2019, 10:29 AM.

Details

Reviewers
dfaure
Group Reviewers
Plasma
Summary

Related diff D19784

BUG: 401579

Diff Detail

Repository
R119 Plasma Desktop
Branch
arcpatch-D23198
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 15453
Build 15471: arc lint + arc unit
meven created this revision.Aug 16 2019, 10:29 AM
Restricted Application added a project: Plasma. · View Herald TranscriptAug 16 2019, 10:29 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
meven requested review of this revision.Aug 16 2019, 10:29 AM

fileSystemType calls statvfs which might also block, so I don't think this helps.

applets/kicker/plugin/recentusagemodel.cpp
254

toLocalFile() instead of path()

meven updated this revision to Diff 63859.Aug 16 2019, 12:40 PM

Use toLocalFile() instead of path()

meven marked an inline comment as done.Aug 16 2019, 12:40 PM

fileSystemType calls statvfs which might also block, so I don't think this helps.

True, but then that implies that KFileItem::isSlow() which has the same code is flawed in the same way.

meven added a comment.Aug 16 2019, 4:27 PM

fileSystemType calls statvfs which might also block, so I don't think this helps.

True, but then that implies that KFileItem::isSlow() which has the same code is flawed in the same way.

Well I had the same reflection in https://phabricator.kde.org/D19784#503088 but after reflection it is ok :

A file whose filesystem is not mounted, is a non-existing file which statvfs report as its error ENOENT http://man7.org/linux/man-pages/man3/statvfs.3.html
I still have to test it at home where I have a nfs setup.

meven added a comment.Aug 16 2019, 4:56 PM
This comment was removed by meven.

True, but then that implies that KFileItem::isSlow() which has the same code is flawed in the same way.

It is. We have ironic lockups there.

meven added a comment.Aug 22 2019, 9:55 AM

True, but then that implies that KFileItem::isSlow() which has the same code is flawed in the same way.

It is. We have ironic lockups there.

Indeed after testing a staled nfs mount will block statvfs until network is back up.

meven updated this revision to Diff 64283.Aug 22 2019, 10:31 AM

Use solid to find network shares

My last change is more a Proof of Concept : using Solid to avoid mime check.
I would be in favor of adding a static function to Solid encompassing this use case.
For instance :
bool Solid::isMountedOnNetworkShare(const QString &filePath) static;

But the good part is that this solution actually works, we get back icons for local files and don't block plasma with a stale mount.

I am open for suggestion.

Why not do this in KFileItem::isSlow() itself?
(and enable SkipMimeTypeFromContent when isSlow is true)

Why not do this in KFileItem::isSlow() itself?
(and enable SkipMimeTypeFromContent when isSlow is true)

First because KFileItem::isSlow is a member function of KFileItem and this code is used to select the correct constructor of KFileItem in the first place...
Second I already tried using KFileItem::isSlow method i.e KFileSystemType::fileSystemType and statvfs syscall in a previous attempt in this diff and it was not usable for this context :
statvfs block the thread in case of a stale network mount until the network is back up (case of a nfs mounted when network is cut).
Meaning it would freeze plasmashell when the case occurred, and shows that KFileItem::isSlow/KFileSystemType::fileSystemType cause freezes whenever they are used for a file on a network stale mount.

This new method is actually implementing what I suggested in https://phabricator.kde.org/D19784#502503

What I mean is:

  1. improve KFileItem::isSlow to use this Solid code
  2. improve KFileItem to enable SkipMimeTypeFromContent automatically if isSlow is true

However maybe we don't want that in dolphin? Not sure. (In that case a new enum value can be added, to disable some features "if slow".)

In any case I see no reason for this code to be in recentusagemodel, it's just one out of many KFileItem users, with similar needs as most others.

(And all this is the reason I hate network mounts, and the much-requested fuse-kio integration... what looks like a local path ends up being unusable as a local path and needs special treatment anyway...)

meven added a comment.Aug 24 2019, 5:26 PM

What I mean is:

  1. improve KFileItem::isSlow to use this Solid code
  2. improve KFileItem to enable SkipMimeTypeFromContent automatically if isSlow is true

Sorry I misread you.

However maybe we don't want that in dolphin? Not sure. (In that case a new enum value can be added, to disable some features "if slow".)

That could be a good idea, allowing users to prevent freezes.

In any case I see no reason for this code to be in recentusagemodel, it's just one out of many KFileItem users, with similar needs as most others.

Yes I thought so, https://phabricator.kde.org/D23198#516506

I really don't like the "isSlow" naming, it hides its meaning, network filesystem aren't necessarly slow, "isNetworkMounted" or similar would be more descriptive IMHO.

meven added a comment.Aug 24 2019, 5:44 PM
This comment was removed by meven.
meven added a comment.Aug 25 2019, 8:33 AM

What I mean is:

  1. improve KFileItem::isSlow to use this Solid code

diff at D23420

So I guess we can use the KFileItem::isSlow() here now, too?

meven added a comment.Sep 2 2019, 6:42 AM

So I guess we can use the KFileItem::isSlow() here now, too?

No because isSlow is a member function but the purpose here is to choose a constructor for KFileItem in the first place.
Hence my idea to have a function encompassing this in a library, because this ought to be reused.

My suggestion is (still) "improve KFileItem to enable SkipMimeTypeFromContent automatically if isSlow is true"
[possibly with another flag if you think there are actually use cases for mime-magic over network mounts]

Then all this code isn't needed.

What's the current status of this patch?