mirage / irmin-watcher

Portable implementation of the Irmin Watch API
ISC License
14 stars 15 forks source link

Crashes if a file is created briefly (e.g. a Git lock file) #20

Closed talex5 closed 5 years ago

talex5 commented 5 years ago

e.g.

irw-inotify [DEBUG] inotify: /tmp/repo/.git/refs/heads/master.lock [CREATE]
Fatal error: exception (Sys_error
  "/tmp/repo/.git/refs/heads/master.lock: No such file or directory")

I suspect this is due to:

let read_file ~prefix f =
  if not (Sys.file_exists f) || Sys.is_directory f then None

Changing it to if not (Sys.file_exists f) || (Unix.sleepf 0.1; Sys.is_directory f) then None makes it crash reliably.

BTW, a couple of other things I noticed while tracking this down: