FAQ
Thx you all for the tips.

Le vendredi 24 juillet 2015 08:59:55 UTC+2, Michael Schaller a écrit :
Inotify is definitely the solution for this problem. In general code that
handles inotify events needs to be extremely fault tolerant because there
are a lot of race conditions. Additionally there are a few more things to
watch out for:

First of all you need to watch the right inotify events. You can use
pyinotify by running 'python -m pyinotify -v /my-dir-to-watch' to get an
idea which events you need to handle and how to distinguish between
different cases.

Secondly, you might want to consider several variants how files can be
created:
1) Normal file creation, write, close.
2) Overwrite an existing file, write, close.
3) Temporary file creation, write, close and then move to the final
location (same filesystem).
4) Temporary file creation, write, close and then move to the final
location (different filesystem).
5) Hardlink creation.
6) Softlink creation. Link target exists.
7) Softlink creation. Link target doesn't exist (yet).

Thirdly, whatever you watch via inotify is not watched via its name/path
but via its inode. If that inode changes because for an instance a whole
directory gets moved/replaced then inotify will not be able to detect these
changes unless the parent directory is also watched via inotify.

Lastly you might also have to watch out for permission/ownership changes.
These can be an additional source of race conditions.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 5 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 23, '15 at 4:14p
activeJul 24, '15 at 12:41p
posts5
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase