Use KDirWatch removeDir/addDir instead of stopDirScan/restartDirScan
Needs RevisionPublic

Authored by dfaure on May 14 2017, 6:42 PM.

Details

Summary

This fixes notifications happening against our will given that inotify
is async.

Test Plan

copying/deleting files in dolphin still updates the view

Diff Detail

Repository
R241 KIO
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
dfaure created this revision.May 14 2017, 6:42 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 14 2017, 6:42 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
aacid edited edge metadata.May 14 2017, 9:15 PM

Do we want to mark the "old" methods as deprecated?

Update the docu?

Yes, if this is confirmed to work we can deprecate stopDirScan/restartDirScan.

It's kind of harmless i guess, but when doing a rename via F2 in dolphin we do stopDirScan on the url twice, one in CopyJobPrivate::startRenameJob and another in CopyJobPrivate::createNextDir
that means you get the following warning
org.kde.kcoreaddons: doesn't know "/home/tsdgeos/bcnfs.github.io/sponsoring/"

Do we care?

In fact, CopyJob has no way to know whether a view somewhere is watching that directory. When an app other than Dolphin uses CopyJob, there isn't going to be any watching, possibly.
So I think we need to remove the qDebug in KDirWatch so that removeDir is silent if the dir wasn't watched [this is faster than checking before removing, from the outside].

At the same time, this shows that the CopyJob handling of m_parentDirs can be improved a little bit. Posting an update.

dfaure updated this revision to Diff 14545.May 15 2017, 12:53 PM

avoid doing removeDir twice

So I think we need to remove the qDebug in KDirWatch so that removeDir is silent if the dir wasn't watched [this is faster than checking before removing, from the outside].

+1

aacid accepted this revision.May 21 2017, 10:15 PM

About the code itself, it looks good, and i've tested dolphin with copy and removes and it seems ok, but on the other hand i understand this is mostly an optimization, so i'm not sure if i would be able to see if it wasn't working fine.

I'm going to say, if we don't have anyone else that can review this, take my +1.

If there's anyone else, i'd be happy to get a second opinion :)

This revision is now accepted and ready to land.May 21 2017, 10:15 PM

I know what the problem is with this.
Previously, if nobody was watching the directory, stopDirScan/restartDirScan would basically do nothing.
Now, after running a kio job in that directory, KDirWatch will start watching it, for no purpose, due to the unconditional addDir().

I guess this needs checks with KDirWatch::contains() before removeDir to only call addDir on dirs that were actually watched in the first place...

aacid requested changes to this revision.May 28 2017, 8:26 PM
This revision now requires changes to proceed.May 28 2017, 8:26 PM
This revision was automatically updated to reflect the committed changes.
dfaure reopened this revision.Jun 3 2017, 10:36 AM
aacid requested changes to this revision.Jan 2 2018, 4:00 PM

Seems this needed changes, was pushed by mistake, then reverted and thus it stayed in the "albert needs to review" state instead of the "david needs to do changes" state.

This revision now requires changes to proceed.Jan 2 2018, 4:00 PM
meven added a subscriber: meven.Aug 20 2019, 7:51 AM

ping @dfaure

Is it still valid ?

Restricted Application edited subscribers, added: kde-frameworks-devel; removed: Frameworks. · View Herald TranscriptAug 20 2019, 7:51 AM

Probably still valid, yes. Needs investigation, and a unittest....