malthe/macfsevents — pull request #11 by mandel-macaque (2012-08-27 10:38:38+00:00)
Title: Ubuntuone API changes

Hello,

This pull request has the following changes that were made in order to fix some small isues found when working with macfsevents on ubuntuone.

###### Added a latency keyword argument ######

While the default 0.01 value should be enough to most applications, we noticed that we would like to be able to provide other values. We have done so by adding a new keyword argument to the Observer constructor. Now, if no value is provided, the default will be used, that is 0.01, else, the specified values will be used.

Because it was added as a keyword argument we expect this change not to affect any other users of the lib.

###### Added a process_asap flag ######

This changes is a little more controversial than the others. The idea is that the events are processed as soon as possible and do not wait until all the streams have been added. This is due to the requirements of ubuntuone. Again, we have added a new keyword argument set as False by default to allow other developers use this feature without being affected by the change.

###### Made _fsevents.schedule deal with file events ######

This change allows for better granularity when receiving events. The change is very straight forward, simply pay more attention to the file events.

###### Ensure that IN_MODIFY events are correctly sent ######

If you see the diff you will notice that we have change the following line:

```python
if stat.st_mtime > snap_stat.st_mtime:
```
for

```python
if stat.st_mtime != snap_stat.st_mtime:
```

this was done because IN_MODIFY events were not raised correctly and instead an IN_CREATE would be raised.

###### Ensure that after an IN_CREATE there is an IN_MODIFY ######

There are several cases in which you will get a single IN_CREATE event with the current upstream implementation:

- When the file is very small and both events are merged in a single one.
- When there is a slow transfer for file, for example, moving from a samba share.
- In a Drag & Drop operation from the finder.
- In a copy operation from the finder.

We have changed the lib so that the IN_CREATE does have the IN_MODIFY operation following the way in which pyinotify deals with the events. This will allow other developers to know when a file was created and when the file system stopped writing to the file.