howeyc/fsnotify

double events and no tracking after rename

Closed this issue · 5 comments

Hello,
When I do 'echo something > foo' I get two modify events for foo. Just curious. Perhaps that is just what you get from the kernel, and I have to deal with it somehow.
Also, after a rename of a watched file, fsnotify no longer watches either the old or new inodes. Is this normal, and if so, is there way to continue with the new inode? I tried to remove then re-add, but that didn't work either.

thanks for sharing your project!

I'll take a look. Assuming this is Linux?
But I'll check others to see if I can reproduce.

Hi,
I also encountered the same problems such,we do the test, all the normal,
but, the problem to coding listener, such as code:
package main

import (
"flag"
"log"
"net/http"

"github.com/howeyc/fsnotify"

)

func main(){
var httpListen = flag.String("http", "127.0.0.1:8080", "host:port to listen on")

watcher, err := fsnotify.NewWatcher()
    defer watcher.Close()
if err != nil {
    log.Fatal(err)
}

go func() {
    for {
        select {
        case ev := <-watcher.Event:
            log.Println("event:", ev)
        case err := <-watcher.Error:
            log.Println("error:", err)

        }
    }
}()

err = watcher.Watch("/home/myname")
if err != nil {
    log.Fatal(err)
}

    log.Printf("Open your web browser and visit http://%s/", *httpListen)
log.Fatal(http.ListenAndServe(*httpListen, nil))

}

Run it output:

2012/07/03 13:43:29 Open your web browser and visit http://127.0.0.1:8080/
2012/07/03 13:43:33 event: "/home/myname": CREATE
2012/07/03 13:43:33 event: "/home/myname": MODIFY
2012/07/03 13:43:33 event: "/home/myname": MODIFY
2012/07/03 13:43:45 event: "/home/myname": CREATE
2012/07/03 13:43:45 event: "/home/myname": MODIFY
2012/07/03 13:43:45 event: "/home/myname": MODIFY
2012/07/03 13:43:45 event: "/home/myname": MODIFY
gedit editor dir /home/myname one file, used two to save.......

Is this normal?or a problem with my program?

my OS is fedora17

Look forward to answering. thanks.

on Linux at least, the IN_MODIFY event AFAICS is working as expected. If you're only interested in the fact that someone just saved the file then you probably want to listen for IN_CLOSE_WRITE

My Linux 3.0 x64 and Win7 x64 machines at work yield double events. But on my Win7 x64 at home, it works great. I'll double chek my code. It's very possible I am doing something stupid!


Pithy comment here.

On Jul 2, 2012, at 6:04 PM, Chris Howeyreply@reply.github.com wrote:

I'll take a look. Assuming this is Linux?
But I'll check others to see if I can reproduce.


Reply to this email directly or view it on GitHub:
#10 (comment)

I get double events consistently on x64 Ubuntu 12.04 Go1 and "inotifywait" yields only 1 event for the same "event".