Skip to content

Commit

Permalink
inotify: dont fire modify event on IN_CLOSE_WRITE
Browse files Browse the repository at this point in the history
  • Loading branch information
tamland committed Nov 6, 2013
1 parent d091e0d commit ce92680
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/watchdog/observers/inotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,10 +769,6 @@ def queue_events(self, timeout):
klass = ACTION_EVENT_MAP[(event.is_directory,
EVENT_TYPE_MODIFIED)]
self.queue_event(klass(event.src_path))
elif event.is_close_write:
klass = ACTION_EVENT_MAP[(event.is_directory,
EVENT_TYPE_MODIFIED)]
self.queue_event(klass(event.src_path))
elif event.is_modify:
klass = ACTION_EVENT_MAP[(event.is_directory,
EVENT_TYPE_MODIFIED)]
Expand Down

8 comments on commit ce92680

@malthe
Copy link

@malthe malthe commented on ce92680 Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But IS_CLOSE_WRITE is a very important event – surely the right thing to do here is to map it to a new event type?

@tamland
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But is closing a file modifying it though? If you map IS_CLOSE_WRITE like this, it will report the file is modified when it isn't actually modified.

@malthe
Copy link

@malthe malthe commented on ce92680 Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opening a file for writing always modifies the file in the sense that it'll update its timestamp and make a new inode.

@tamland
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure mtime is only update when you actually write something. That's why it went with removing it.

@malthe
Copy link

@malthe malthe commented on ce92680 Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mtime field is updated every time you flush changes to disk. Now, when the file is closed (which is an interesting event for many programs), the IN_CLOSE_WRITE event is issued.

@malthe
Copy link

@malthe malthe commented on ce92680 Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't respond to this event, users of the library can't know if a file was closed, usually the trigger for starting to do some processing.

@tamland
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but before this commit it wasn't possible to respond to that either. It was mapped a to modified event, that looked like a normal modified event and that you would have already gotten from a previous IN_MODIFIED event. I don't understand how this commit changes anything.

@malthe
Copy link

@malthe malthe commented on ce92680 Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit doesn't change anything, that is true – I just saw it disappearing altogether and wanted to investigate where it went and why it wasn't replaced by a proper implementation. By the way, I made a pull request that tries to implement it. Untested though.

Ultimately, I decided to just use the subprocess module to poll from inotifywait.

Please sign in to comment.