Skip to content

Different behaviour in poll and inotify backend #43

@panglesd

Description

@panglesd

Continuing my issue streak :)

In polling mode, the whole directory watched is re-traversed and md5summed every $n$ seconds. All file changes, including in subdirectories, trigger a callback.
In inotify mode, the current directory is watched by inotify and only changes in this directory trigger a callback (but a whole scan at the beginning is still done: #41)

Thus, the behaviour is different. Here is an example:

let callback filename =
  Format.printf "modification to %s\n%!" filename;
  Lwt.return ()

let hook =
  if Sys.argv.(1) = "polling" then
    Irmin_watcher__.Core.hook (Lazy.force Irmin_watcher__Polling.v)
  else Irmin_watcher.hook

let never_ends =
  let wait, _ = Lwt.wait () in
  wait

let () =
  let parent = "./" in
  let open Lwt.Syntax in
  Lwt_main.run
  @@
  let* _cancel = hook 0 parent callback in
  never_ends

Now, call this in polling mode, in a directory , and modify a file in a subdirectory (bin/aaa):

$ ./_build/default/bin/main.exe "polling"
modification to bin/aaa

And the same in inotify mode:

$ ./_build/default/bin/main.exe "inotify"

no modification detected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions