From 9f4a68c904777b860b79fc37ca1d9aaf6a4c1490 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Wed, 26 Aug 2020 01:28:29 -0400 Subject: [PATCH] Tweak vendoring to include rfsnotify which has recursive support via fsnotify --- go.mod | 4 +- go.sum | 4 + .../github.com/dietsche/rfsnotify/.gitignore | 24 ++++ vendor/github.com/dietsche/rfsnotify/LICENSE | 22 +++ .../github.com/dietsche/rfsnotify/README.md | 21 +++ .../dietsche/rfsnotify/rfsnotify.go | 133 ++++++++++++++++++ .../fsnotify/fsnotify/.editorconfig | 12 -- .../fsnotify/fsnotify/.gitattributes | 1 - .../github.com/fsnotify/fsnotify/.travis.yml | 36 ----- vendor/github.com/fsnotify/fsnotify/go.mod | 5 - vendor/github.com/fsnotify/fsnotify/go.sum | 2 - vendor/gopkg.in/fsnotify.v1/.editorconfig | 5 + .../fsnotify.v1}/.gitignore | 0 vendor/gopkg.in/fsnotify.v1/.travis.yml | 30 ++++ .../fsnotify => gopkg.in/fsnotify.v1}/AUTHORS | 0 .../fsnotify.v1}/CHANGELOG.md | 0 .../fsnotify.v1}/CONTRIBUTING.md | 0 .../fsnotify => gopkg.in/fsnotify.v1}/LICENSE | 2 +- .../fsnotify.v1}/README.md | 71 ++-------- .../fsnotify => gopkg.in/fsnotify.v1}/fen.go | 0 .../fsnotify.v1}/fsnotify.go | 4 +- .../fsnotify.v1}/inotify.go | 0 .../fsnotify.v1}/inotify_poller.go | 4 +- .../fsnotify.v1}/kqueue.go | 0 .../fsnotify.v1}/open_mode_bsd.go | 2 +- .../fsnotify.v1}/open_mode_darwin.go | 2 +- .../fsnotify.v1}/windows.go | 0 vendor/modules.txt | 7 +- 28 files changed, 264 insertions(+), 127 deletions(-) create mode 100644 vendor/github.com/dietsche/rfsnotify/.gitignore create mode 100644 vendor/github.com/dietsche/rfsnotify/LICENSE create mode 100644 vendor/github.com/dietsche/rfsnotify/README.md create mode 100644 vendor/github.com/dietsche/rfsnotify/rfsnotify.go delete mode 100644 vendor/github.com/fsnotify/fsnotify/.editorconfig delete mode 100644 vendor/github.com/fsnotify/fsnotify/.gitattributes delete mode 100644 vendor/github.com/fsnotify/fsnotify/.travis.yml delete mode 100644 vendor/github.com/fsnotify/fsnotify/go.mod delete mode 100644 vendor/github.com/fsnotify/fsnotify/go.sum create mode 100644 vendor/gopkg.in/fsnotify.v1/.editorconfig rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/.gitignore (100%) create mode 100644 vendor/gopkg.in/fsnotify.v1/.travis.yml rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/AUTHORS (100%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/CHANGELOG.md (100%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/CONTRIBUTING.md (100%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/LICENSE (95%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/README.md (53%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/fen.go (100%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/fsnotify.go (95%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/inotify.go (100%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/inotify_poller.go (97%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/kqueue.go (100%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/open_mode_bsd.go (79%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/open_mode_darwin.go (84%) rename vendor/{github.com/fsnotify/fsnotify => gopkg.in/fsnotify.v1}/windows.go (100%) diff --git a/go.mod b/go.mod index 55b1a50..9e7b364 100644 --- a/go.mod +++ b/go.mod @@ -7,5 +7,7 @@ require ( github.com/d2r2/go-i2c v0.0.0-20191123181816-73a8a799d6bc github.com/d2r2/go-logger v0.0.0-20181221090742-9998a510495e github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fsnotify/fsnotify v1.4.9 + github.com/dietsche/rfsnotify v0.0.0-20200716145600-b37be6e4177f + github.com/fsnotify/fsnotify v1.4.9 // indirect + gopkg.in/fsnotify.v1 v1.4.7 // indirect ) diff --git a/go.sum b/go.sum index fe0b22e..89cdf0f 100644 --- a/go.sum +++ b/go.sum @@ -6,7 +6,11 @@ github.com/d2r2/go-logger v0.0.0-20181221090742-9998a510495e h1:ZG3JBA6rPRl0xxQ+ github.com/d2r2/go-logger v0.0.0-20181221090742-9998a510495e/go.mod h1:oA+9PUt8F1aKJ6o4YU1T120i7sgo1T6/1LWEEBy0BSs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dietsche/rfsnotify v0.0.0-20200716145600-b37be6e4177f h1:b3QvpXLSx1U13VM79rSkA+6Xv4lmT/urEMzA36Yma0U= +github.com/dietsche/rfsnotify v0.0.0-20200716145600-b37be6e4177f/go.mod h1:ztitxkMUaBsHRey1tS5xFCd4gm/zAQwA9yfCP5y4cAA= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9 h1:L2auWcuQIvxz9xSEqzESnV/QN/gNRXNApHi3fYwl2w0= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= diff --git a/vendor/github.com/dietsche/rfsnotify/.gitignore b/vendor/github.com/dietsche/rfsnotify/.gitignore new file mode 100644 index 0000000..daf913b --- /dev/null +++ b/vendor/github.com/dietsche/rfsnotify/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/dietsche/rfsnotify/LICENSE b/vendor/github.com/dietsche/rfsnotify/LICENSE new file mode 100644 index 0000000..bed7d34 --- /dev/null +++ b/vendor/github.com/dietsche/rfsnotify/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Gregory L. Dietsche + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/vendor/github.com/dietsche/rfsnotify/README.md b/vendor/github.com/dietsche/rfsnotify/README.md new file mode 100644 index 0000000..428c5cc --- /dev/null +++ b/vendor/github.com/dietsche/rfsnotify/README.md @@ -0,0 +1,21 @@ +# rfsnotify v0.1.0 +recursive directory notifications built as a wrapper around fsnotify (golang) + +[![GoDoc](https://godoc.org/github.com/dietsche/rfsnotify?status.svg)](https://godoc.org/github.com/dietsche/rfsnotify) + +This is a thin wrapper around https://github.com/fsnotify/fsnotify instead of only monitoring a top level folder, +it allows you to monitor all folders underneath the folder you specify. + +Example: +-------- +(error handling omitted to improve readability) +``` + import "github.com/dietsche/rfsnotify" + +//rfsnotify works exactly like fsnotify and implements the same API. + watcher, err := rfsnotify.NewWatcher() + +//rfsnotify adds two new API entry points: + watcher.AddRecursive("/tmp/") + watcher.RemoveRecursive("/tmp/") +``` diff --git a/vendor/github.com/dietsche/rfsnotify/rfsnotify.go b/vendor/github.com/dietsche/rfsnotify/rfsnotify.go new file mode 100644 index 0000000..7ba95ac --- /dev/null +++ b/vendor/github.com/dietsche/rfsnotify/rfsnotify.go @@ -0,0 +1,133 @@ +// Package rfsnotify implements recursive folder monitoring by wrapping the excellent fsnotify library +package rfsnotify + +import ( + "gopkg.in/fsnotify.v1" + + "errors" + "os" + "path/filepath" +) + +// RWatcher wraps fsnotify.Watcher. When fsnotify adds recursive watches, you should be able to switch your code to use fsnotify.Watcher +type RWatcher struct { + Events chan fsnotify.Event + Errors chan error + + done chan struct{} + fsnotify *fsnotify.Watcher + isClosed bool +} + +// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events. +func NewWatcher() (*RWatcher, error) { + fsWatch, err := fsnotify.NewWatcher() + if err != nil { + return nil, err + } + + m := &RWatcher{} + m.fsnotify = fsWatch + m.Events = make(chan fsnotify.Event) + m.Errors = make(chan error) + m.done = make(chan struct{}) + + go m.start() + + return m, nil +} + +// Add starts watching the named file or directory (non-recursively). +func (m *RWatcher) Add(name string) error { + if m.isClosed { + return errors.New("rfsnotify instance already closed") + } + return m.fsnotify.Add(name) +} + +// AddRecursive starts watching the named directory and all sub-directories. +func (m *RWatcher) AddRecursive(name string) error { + if m.isClosed { + return errors.New("rfsnotify instance already closed") + } + if err := m.watchRecursive(name, false); err != nil { + return err + } + return nil +} + +// Remove stops watching the the named file or directory (non-recursively). +func (m *RWatcher) Remove(name string) error { + return m.fsnotify.Remove(name) +} + +// RemoveRecursive stops watching the named directory and all sub-directories. +func (m *RWatcher) RemoveRecursive(name string) error { + if err := m.watchRecursive(name, true); err != nil { + return err + } + return nil +} + +// Close removes all watches and closes the events channel. +func (m *RWatcher) Close() error { + if m.isClosed { + return nil + } + close(m.done) + m.isClosed = true + return nil +} + +func (m *RWatcher) start() { + for { + select { + + case e := <-m.fsnotify.Events: + s, err := os.Stat(e.Name) + if err == nil && s != nil && s.IsDir() { + if e.Op&fsnotify.Create != 0 { + m.watchRecursive(e.Name, false) + } + } + //Can't stat a deleted directory, so just pretend that it's always a directory and + //try to remove from the watch list... we really have no clue if it's a directory or not... + if e.Op&fsnotify.Remove != 0 { + m.fsnotify.Remove(e.Name) + } + m.Events <- e + + case e := <-m.fsnotify.Errors: + m.Errors <- e + + case <-m.done: + m.fsnotify.Close() + close(m.Events) + close(m.Errors) + return + } + } +} + +// watchRecursive adds all directories under the given one to the watch list. +// this is probably a very racey process. What if a file is added to a folder before we get the watch added? +func (m *RWatcher) watchRecursive(path string, unWatch bool) error { + err := filepath.Walk(path, func(walkPath string, fi os.FileInfo, err error) error { + if err != nil { + return err + } + if fi.IsDir() { + if unWatch { + if err = m.fsnotify.Remove(walkPath); err != nil { + return err + } + } else { + if err = m.fsnotify.Add(walkPath); err != nil { + return err + } + } + } + return nil + }) + return err +} diff --git a/vendor/github.com/fsnotify/fsnotify/.editorconfig b/vendor/github.com/fsnotify/fsnotify/.editorconfig deleted file mode 100644 index fad8958..0000000 --- a/vendor/github.com/fsnotify/fsnotify/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -root = true - -[*.go] -indent_style = tab -indent_size = 4 -insert_final_newline = true - -[*.{yml,yaml}] -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true diff --git a/vendor/github.com/fsnotify/fsnotify/.gitattributes b/vendor/github.com/fsnotify/fsnotify/.gitattributes deleted file mode 100644 index 32f1001..0000000 --- a/vendor/github.com/fsnotify/fsnotify/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -go.sum linguist-generated diff --git a/vendor/github.com/fsnotify/fsnotify/.travis.yml b/vendor/github.com/fsnotify/fsnotify/.travis.yml deleted file mode 100644 index a9c3016..0000000 --- a/vendor/github.com/fsnotify/fsnotify/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -sudo: false -language: go - -go: - - "stable" - - "1.11.x" - - "1.10.x" - - "1.9.x" - -matrix: - include: - - go: "stable" - env: GOLINT=true - allow_failures: - - go: tip - fast_finish: true - - -before_install: - - if [ ! -z "${GOLINT}" ]; then go get -u golang.org/x/lint/golint; fi - -script: - - go test --race ./... - -after_script: - - test -z "$(gofmt -s -l -w . | tee /dev/stderr)" - - if [ ! -z "${GOLINT}" ]; then echo running golint; golint --set_exit_status ./...; else echo skipping golint; fi - - go vet ./... - -os: - - linux - - osx - - windows - -notifications: - email: false diff --git a/vendor/github.com/fsnotify/fsnotify/go.mod b/vendor/github.com/fsnotify/fsnotify/go.mod deleted file mode 100644 index ff11e13..0000000 --- a/vendor/github.com/fsnotify/fsnotify/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/fsnotify/fsnotify - -go 1.13 - -require golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9 diff --git a/vendor/github.com/fsnotify/fsnotify/go.sum b/vendor/github.com/fsnotify/fsnotify/go.sum deleted file mode 100644 index f60af98..0000000 --- a/vendor/github.com/fsnotify/fsnotify/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9 h1:L2auWcuQIvxz9xSEqzESnV/QN/gNRXNApHi3fYwl2w0= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/vendor/gopkg.in/fsnotify.v1/.editorconfig b/vendor/gopkg.in/fsnotify.v1/.editorconfig new file mode 100644 index 0000000..ba49e3c --- /dev/null +++ b/vendor/gopkg.in/fsnotify.v1/.editorconfig @@ -0,0 +1,5 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 diff --git a/vendor/github.com/fsnotify/fsnotify/.gitignore b/vendor/gopkg.in/fsnotify.v1/.gitignore similarity index 100% rename from vendor/github.com/fsnotify/fsnotify/.gitignore rename to vendor/gopkg.in/fsnotify.v1/.gitignore diff --git a/vendor/gopkg.in/fsnotify.v1/.travis.yml b/vendor/gopkg.in/fsnotify.v1/.travis.yml new file mode 100644 index 0000000..981d1bb --- /dev/null +++ b/vendor/gopkg.in/fsnotify.v1/.travis.yml @@ -0,0 +1,30 @@ +sudo: false +language: go + +go: + - 1.8.x + - 1.9.x + - tip + +matrix: + allow_failures: + - go: tip + fast_finish: true + +before_script: + - go get -u github.com/golang/lint/golint + +script: + - go test -v --race ./... + +after_script: + - test -z "$(gofmt -s -l -w . | tee /dev/stderr)" + - test -z "$(golint ./... | tee /dev/stderr)" + - go vet ./... + +os: + - linux + - osx + +notifications: + email: false diff --git a/vendor/github.com/fsnotify/fsnotify/AUTHORS b/vendor/gopkg.in/fsnotify.v1/AUTHORS similarity index 100% rename from vendor/github.com/fsnotify/fsnotify/AUTHORS rename to vendor/gopkg.in/fsnotify.v1/AUTHORS diff --git a/vendor/github.com/fsnotify/fsnotify/CHANGELOG.md b/vendor/gopkg.in/fsnotify.v1/CHANGELOG.md similarity index 100% rename from vendor/github.com/fsnotify/fsnotify/CHANGELOG.md rename to vendor/gopkg.in/fsnotify.v1/CHANGELOG.md diff --git a/vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md b/vendor/gopkg.in/fsnotify.v1/CONTRIBUTING.md similarity index 100% rename from vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md rename to vendor/gopkg.in/fsnotify.v1/CONTRIBUTING.md diff --git a/vendor/github.com/fsnotify/fsnotify/LICENSE b/vendor/gopkg.in/fsnotify.v1/LICENSE similarity index 95% rename from vendor/github.com/fsnotify/fsnotify/LICENSE rename to vendor/gopkg.in/fsnotify.v1/LICENSE index e180c8f..f21e540 100644 --- a/vendor/github.com/fsnotify/fsnotify/LICENSE +++ b/vendor/gopkg.in/fsnotify.v1/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2012 The Go Authors. All rights reserved. -Copyright (c) 2012-2019 fsnotify Authors. All rights reserved. +Copyright (c) 2012 fsnotify Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are diff --git a/vendor/github.com/fsnotify/fsnotify/README.md b/vendor/gopkg.in/fsnotify.v1/README.md similarity index 53% rename from vendor/github.com/fsnotify/fsnotify/README.md rename to vendor/gopkg.in/fsnotify.v1/README.md index b2629e5..3993207 100644 --- a/vendor/github.com/fsnotify/fsnotify/README.md +++ b/vendor/gopkg.in/fsnotify.v1/README.md @@ -10,16 +10,16 @@ go get -u golang.org/x/sys/... Cross platform: Windows, Linux, BSD and macOS. -| Adapter | OS | Status | -| --------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | -| inotify | Linux 2.6.27 or later, Android\* | Supported [![Build Status](https://travis-ci.org/fsnotify/fsnotify.svg?branch=master)](https://travis-ci.org/fsnotify/fsnotify) | -| kqueue | BSD, macOS, iOS\* | Supported [![Build Status](https://travis-ci.org/fsnotify/fsnotify.svg?branch=master)](https://travis-ci.org/fsnotify/fsnotify) | -| ReadDirectoryChangesW | Windows | Supported [![Build Status](https://travis-ci.org/fsnotify/fsnotify.svg?branch=master)](https://travis-ci.org/fsnotify/fsnotify) | -| FSEvents | macOS | [Planned](https://github.com/fsnotify/fsnotify/issues/11) | -| FEN | Solaris 11 | [In Progress](https://github.com/fsnotify/fsnotify/issues/12) | -| fanotify | Linux 2.6.37+ | [Planned](https://github.com/fsnotify/fsnotify/issues/114) | -| USN Journals | Windows | [Maybe](https://github.com/fsnotify/fsnotify/issues/53) | -| Polling | *All* | [Maybe](https://github.com/fsnotify/fsnotify/issues/9) | +|Adapter |OS |Status | +|----------|----------|----------| +|inotify |Linux 2.6.27 or later, Android\*|Supported [![Build Status](https://travis-ci.org/fsnotify/fsnotify.svg?branch=master)](https://travis-ci.org/fsnotify/fsnotify)| +|kqueue |BSD, macOS, iOS\*|Supported [![Build Status](https://travis-ci.org/fsnotify/fsnotify.svg?branch=master)](https://travis-ci.org/fsnotify/fsnotify)| +|ReadDirectoryChangesW|Windows|Supported [![Build status](https://ci.appveyor.com/api/projects/status/ivwjubaih4r0udeh/branch/master?svg=true)](https://ci.appveyor.com/project/NathanYoungman/fsnotify/branch/master)| +|FSEvents |macOS |[Planned](https://github.com/fsnotify/fsnotify/issues/11)| +|FEN |Solaris 11 |[In Progress](https://github.com/fsnotify/fsnotify/issues/12)| +|fanotify |Linux 2.6.37+ | | +|USN Journals |Windows |[Maybe](https://github.com/fsnotify/fsnotify/issues/53)| +|Polling |*All* |[Maybe](https://github.com/fsnotify/fsnotify/issues/9)| \* Android and iOS are untested. @@ -33,53 +33,6 @@ All [releases](https://github.com/fsnotify/fsnotify/releases) are tagged based o Go 1.6 supports dependencies located in the `vendor/` folder. Unless you are creating a library, it is recommended that you copy fsnotify into `vendor/github.com/fsnotify/fsnotify` within your project, and likewise for `golang.org/x/sys`. -## Usage - -```go -package main - -import ( - "log" - - "github.com/fsnotify/fsnotify" -) - -func main() { - watcher, err := fsnotify.NewWatcher() - if err != nil { - log.Fatal(err) - } - defer watcher.Close() - - done := make(chan bool) - go func() { - for { - select { - case event, ok := <-watcher.Events: - if !ok { - return - } - log.Println("event:", event) - if event.Op&fsnotify.Write == fsnotify.Write { - log.Println("modified file:", event.Name) - } - case err, ok := <-watcher.Errors: - if !ok { - return - } - log.Println("error:", err) - } - } - }() - - err = watcher.Add("/tmp/foo") - if err != nil { - log.Fatal(err) - } - <-done -} -``` - ## Contributing Please refer to [CONTRIBUTING][] before opening an issue or pull request. @@ -112,10 +65,6 @@ There are OS-specific limits as to how many watches can be created: * Linux: /proc/sys/fs/inotify/max_user_watches contains the limit, reaching this limit results in a "no space left on device" error. * BSD / OSX: sysctl variables "kern.maxfiles" and "kern.maxfilesperproc", reaching these limits results in a "too many open files" error. -**Why don't notifications work with NFS filesystems or filesystem in userspace (FUSE)?** - -fsnotify requires support from underlying OS to work. The current NFS protocol does not provide network level support for file notifications. - [#62]: https://github.com/howeyc/fsnotify/issues/62 [#18]: https://github.com/fsnotify/fsnotify/issues/18 [#11]: https://github.com/fsnotify/fsnotify/issues/11 diff --git a/vendor/github.com/fsnotify/fsnotify/fen.go b/vendor/gopkg.in/fsnotify.v1/fen.go similarity index 100% rename from vendor/github.com/fsnotify/fsnotify/fen.go rename to vendor/gopkg.in/fsnotify.v1/fen.go diff --git a/vendor/github.com/fsnotify/fsnotify/fsnotify.go b/vendor/gopkg.in/fsnotify.v1/fsnotify.go similarity index 95% rename from vendor/github.com/fsnotify/fsnotify/fsnotify.go rename to vendor/gopkg.in/fsnotify.v1/fsnotify.go index 89cab04..190bf0d 100644 --- a/vendor/github.com/fsnotify/fsnotify/fsnotify.go +++ b/vendor/gopkg.in/fsnotify.v1/fsnotify.go @@ -63,6 +63,4 @@ func (e Event) String() string { } // Common errors that can be reported by a watcher -var ( - ErrEventOverflow = errors.New("fsnotify queue overflow") -) +var ErrEventOverflow = errors.New("fsnotify queue overflow") diff --git a/vendor/github.com/fsnotify/fsnotify/inotify.go b/vendor/gopkg.in/fsnotify.v1/inotify.go similarity index 100% rename from vendor/github.com/fsnotify/fsnotify/inotify.go rename to vendor/gopkg.in/fsnotify.v1/inotify.go diff --git a/vendor/github.com/fsnotify/fsnotify/inotify_poller.go b/vendor/gopkg.in/fsnotify.v1/inotify_poller.go similarity index 97% rename from vendor/github.com/fsnotify/fsnotify/inotify_poller.go rename to vendor/gopkg.in/fsnotify.v1/inotify_poller.go index b33f2b4..cc7db4b 100644 --- a/vendor/github.com/fsnotify/fsnotify/inotify_poller.go +++ b/vendor/gopkg.in/fsnotify.v1/inotify_poller.go @@ -40,12 +40,12 @@ func newFdPoller(fd int) (*fdPoller, error) { poller.fd = fd // Create epoll fd - poller.epfd, errno = unix.EpollCreate1(unix.EPOLL_CLOEXEC) + poller.epfd, errno = unix.EpollCreate1(0) if poller.epfd == -1 { return nil, errno } // Create pipe; pipe[0] is the read end, pipe[1] the write end. - errno = unix.Pipe2(poller.pipe[:], unix.O_NONBLOCK|unix.O_CLOEXEC) + errno = unix.Pipe2(poller.pipe[:], unix.O_NONBLOCK) if errno != nil { return nil, errno } diff --git a/vendor/github.com/fsnotify/fsnotify/kqueue.go b/vendor/gopkg.in/fsnotify.v1/kqueue.go similarity index 100% rename from vendor/github.com/fsnotify/fsnotify/kqueue.go rename to vendor/gopkg.in/fsnotify.v1/kqueue.go diff --git a/vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go b/vendor/gopkg.in/fsnotify.v1/open_mode_bsd.go similarity index 79% rename from vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go rename to vendor/gopkg.in/fsnotify.v1/open_mode_bsd.go index 2306c46..7d8de14 100644 --- a/vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go +++ b/vendor/gopkg.in/fsnotify.v1/open_mode_bsd.go @@ -8,4 +8,4 @@ package fsnotify import "golang.org/x/sys/unix" -const openMode = unix.O_NONBLOCK | unix.O_RDONLY | unix.O_CLOEXEC +const openMode = unix.O_NONBLOCK | unix.O_RDONLY diff --git a/vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go b/vendor/gopkg.in/fsnotify.v1/open_mode_darwin.go similarity index 84% rename from vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go rename to vendor/gopkg.in/fsnotify.v1/open_mode_darwin.go index 870c4d6..9139e17 100644 --- a/vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go +++ b/vendor/gopkg.in/fsnotify.v1/open_mode_darwin.go @@ -9,4 +9,4 @@ package fsnotify import "golang.org/x/sys/unix" // note: this constant is not defined on BSD -const openMode = unix.O_EVTONLY | unix.O_CLOEXEC +const openMode = unix.O_EVTONLY diff --git a/vendor/github.com/fsnotify/fsnotify/windows.go b/vendor/gopkg.in/fsnotify.v1/windows.go similarity index 100% rename from vendor/github.com/fsnotify/fsnotify/windows.go rename to vendor/gopkg.in/fsnotify.v1/windows.go diff --git a/vendor/modules.txt b/vendor/modules.txt index dafbcc2..c92dae1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -10,8 +10,13 @@ github.com/d2r2/go-logger # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew +# github.com/dietsche/rfsnotify v0.0.0-20200716145600-b37be6e4177f +## explicit +github.com/dietsche/rfsnotify # github.com/fsnotify/fsnotify v1.4.9 ## explicit -github.com/fsnotify/fsnotify # golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9 golang.org/x/sys/unix +# gopkg.in/fsnotify.v1 v1.4.7 +## explicit +gopkg.in/fsnotify.v1