[Interest] QFileSystemWatcher and kate

Thiago Macieira thiago.macieira at intel.com
Mon Sep 4 02:17:01 CEST 2017


On Sunday, 3 September 2017 05:21:26 -03 Christian Ehrlicher wrote:
> Hi,
> 
> I stumbled across a problem with QFileSystemWatcher on Linux. It looks
> like the inotify implementation does not honor a file replace action as
> expected.
> I'm adding a file with addPath() to watch for changes. But after I edit
> the file with kate (or any other editor which saves the file in a temp
> file and then renaming it to correct name), the QFileSystemWatcher does
> no longer watch for modifications...
> Looking in the bug tracker I also found a bug which describes the
> problem:
> https://bugreports.qt.io/browse/QTBUG-19350?jql=text%20~%20%22qfilesystemwat
> cher%22 So it looks like this bug exists since inotify support was added but
> the bug report was closed because it was not reproducible (maybe not tested
> with inotify).
> Therefore my question - how to reopen this bug or should I file a new one?

Strictly speaking, the behaviour you're seeing is the correct one: the file you 
were watching was not modified. It was deleted. The new contents do not belong 
to this file, but to another. If you were using tail -f to follow this file you 
wouldn't see anything -- you need -F.

So to fix this issue (the strictly correct behaviour is not the expected one), 
we need to add some other mechanism, like tail's flag above. That's because 
we'll need more resources, as we need to check the directory for change.

I have a vague recollection that if you do just that with QFSW, you'll get the 
notification you want. So simply start watching the directory that contains the 
file you're watching.

I also wonder if inotify can notify you of a change in file metadata. That is, 
can it notify you of a change in st_nlink?

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list