Skip to content
This repository was archived by the owner on Jun 8, 2022. It is now read-only.
This repository was archived by the owner on Jun 8, 2022. It is now read-only.

WatchFlags not supported on Windows? #93

@mstum

Description

@mstum

Hi,
I've setup a watcher like this:

func setupConfigWatcher() {
    configWatcher, err := fsnotify.NewWatcher()
    if err != nil {
        log.Fatal("Setup Config Watcher:",err)
    }

    done := make(chan bool)

    go func() {
        for {
            select {
        case ev := <-configWatcher.Event:
            log.Println("event:", ev)
            if strings.HasSuffix(ev.Name, "obrot-dns.json") && ev.IsModify() {
                loadConfig(true)
                showConfig()
                }
        case err := <-configWatcher.Error:
            log.Println("error:",err)
        }
    }
    }()

    err = configWatcher.WatchFlags("cfg",fsnotify.FSN_MODIFY)

    if err != nil {
        log.Fatal(err)
    }

    <-done
}

The WatchFlags is intended to only watch for modifications. However, this seems to not work, I get CREATE and DELETE and RENAME events as well:

2014/03/22 22:41:43 event: "cfg.obrot-dns.json.swp": CREATE
2014/03/22 22:41:43 event: "cfg.obrot-dns.json.swp": MODIFY
2014/03/22 22:41:48 event: "cfg\4913": CREATE
2014/03/22 22:41:48 event: "cfg\4913": MODIFY
2014/03/22 22:41:48 event: "cfg\4913": DELETE
2014/03/22 22:41:48 event: "cfg\obrot-dns.json": RENAME
2014/03/22 22:41:48 event: "cfg\obrot-dns.json~": RENAME
2014/03/22 22:41:48 event: "cfg\obrot-dns.json~": MODIFY
2014/03/22 22:41:48 event: "cfg\obrot-dns.json": CREATE
2014/03/22 22:41:48 event: "cfg\obrot-dns.json": MODIFY

Is there some limitation in Windows (Win7 x64 on a NTFS drive if it matters)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions