Bug 315410

Summary: KDirWatch - inotify - Any file operation is "dirty".
Product: [Unmaintained] kio Reporter: Mark <markg85>
Component: generalAssignee: David Faure <faure>
Status: RESOLVED INTENTIONAL    
Severity: normal CC: adawit, faure
Priority: NOR    
Version: 4.10.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Mark 2013-02-18 20:00:57 UTC
Hi,

I was playing with KDirWatch and noticed that any file operation that i do is being emitted as a "dirty" signal.

Create file: dirty signal (instead of created)
Modify file: dirty signal (might be fine, but i do get two additional signals here as well. Both of them with the directory in which the file is located. So 3 in total, 1 with the file path, 2 with the directory path)
Delete file: dirty signal (instead of created)

I tried debugging this a bit to narrow it down, but it's quite complicated. Mainly because of some timers in kdirwatch.cpp

Regards,
Mark
Comment 1 Dawit Alemayehu 2014-10-14 12:09:36 UTC
That is by design. The KDirWatch documentation clearly states:

  * Watch directories and files for changes.
  * The watched directories or files don't have to exist yet.
  *
  * When a watched directory is changed, i.e. when files therein are
  * created or deleted, KDirWatch will emit the signal dirty().
  *
  * When a watched, but previously not existing directory gets created,
  * KDirWatch will emit the signal created().
  *
  * When a watched directory gets deleted, KDirWatch will emit the
  * signal deleted(). The directory is still watched for new
  * creation.
  *
  * When a watched file is changed, i.e. attributes changed or written
  * to, KDirWatch will emit the signal dirty().

So created and deleted are emitted for a particular directory you are watching iff the directory itself gets created and deleted. Otherwise, all you get is a dirty signal for anything that happens under that directory.