Browse Source

Tweak vendoring to include rfsnotify which has recursive support via fsnotify

master
KemoNine 1 year ago
parent
commit
9f4a68c904
  1. 4
      go.mod
  2. 4
      go.sum
  3. 24
      vendor/github.com/dietsche/rfsnotify/.gitignore
  4. 22
      vendor/github.com/dietsche/rfsnotify/LICENSE
  5. 21
      vendor/github.com/dietsche/rfsnotify/README.md
  6. 133
      vendor/github.com/dietsche/rfsnotify/rfsnotify.go
  7. 12
      vendor/github.com/fsnotify/fsnotify/.editorconfig
  8. 1
      vendor/github.com/fsnotify/fsnotify/.gitattributes
  9. 36
      vendor/github.com/fsnotify/fsnotify/.travis.yml
  10. 5
      vendor/github.com/fsnotify/fsnotify/go.mod
  11. 2
      vendor/github.com/fsnotify/fsnotify/go.sum
  12. 5
      vendor/gopkg.in/fsnotify.v1/.editorconfig
  13. 0
      vendor/gopkg.in/fsnotify.v1/.gitignore
  14. 30
      vendor/gopkg.in/fsnotify.v1/.travis.yml
  15. 0
      vendor/gopkg.in/fsnotify.v1/AUTHORS
  16. 0
      vendor/gopkg.in/fsnotify.v1/CHANGELOG.md
  17. 0
      vendor/gopkg.in/fsnotify.v1/CONTRIBUTING.md
  18. 2
      vendor/gopkg.in/fsnotify.v1/LICENSE
  19. 71
      vendor/gopkg.in/fsnotify.v1/README.md
  20. 0
      vendor/gopkg.in/fsnotify.v1/fen.go
  21. 4
      vendor/gopkg.in/fsnotify.v1/fsnotify.go
  22. 0
      vendor/gopkg.in/fsnotify.v1/inotify.go
  23. 4
      vendor/gopkg.in/fsnotify.v1/inotify_poller.go
  24. 0
      vendor/gopkg.in/fsnotify.v1/kqueue.go
  25. 2
      vendor/gopkg.in/fsnotify.v1/open_mode_bsd.go
  26. 2
      vendor/gopkg.in/fsnotify.v1/open_mode_darwin.go
  27. 0
      vendor/gopkg.in/fsnotify.v1/windows.go
  28. 7
      vendor/modules.txt

4
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
)

4
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=

24
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

22
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.

21
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/")
```

133
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
}

12
vendor/github.com/fsnotify/fsnotify/.editorconfig

@ -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

1
vendor/github.com/fsnotify/fsnotify/.gitattributes

@ -1 +0,0 @@
go.sum linguist-generated

36
vendor/github.com/fsnotify/fsnotify/.travis.yml

@ -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

5
vendor/github.com/fsnotify/fsnotify/go.mod

@ -1,5 +0,0 @@
module github.com/fsnotify/fsnotify
go 1.13
require golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9

2
vendor/github.com/fsnotify/fsnotify/go.sum

@ -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=

5
vendor/gopkg.in/fsnotify.v1/.editorconfig

@ -0,0 +1,5 @@
root = true
[*]
indent_style = tab
indent_size = 4

0
vendor/github.com/fsnotify/fsnotify/.gitignore → vendor/gopkg.in/fsnotify.v1/.gitignore

30
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

0
vendor/github.com/fsnotify/fsnotify/AUTHORS → vendor/gopkg.in/fsnotify.v1/AUTHORS

0
vendor/github.com/fsnotify/fsnotify/CHANGELOG.md → vendor/gopkg.in/fsnotify.v1/CHANGELOG.md

0
vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md → vendor/gopkg.in/fsnotify.v1/CONTRIBUTING.md

2
vendor/github.com/fsnotify/fsnotify/LICENSE → 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

71
vendor/github.com/fsnotify/fsnotify/README.md → 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

0
vendor/github.com/fsnotify/fsnotify/fen.go → vendor/gopkg.in/fsnotify.v1/fen.go

4
vendor/github.com/fsnotify/fsnotify/fsnotify.go → 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")

0
vendor/github.com/fsnotify/fsnotify/inotify.go → vendor/gopkg.in/fsnotify.v1/inotify.go

4
vendor/github.com/fsnotify/fsnotify/inotify_poller.go → 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
}

0
vendor/github.com/fsnotify/fsnotify/kqueue.go → vendor/gopkg.in/fsnotify.v1/kqueue.go

2
vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go → 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

2
vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go → 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

0
vendor/github.com/fsnotify/fsnotify/windows.go → vendor/gopkg.in/fsnotify.v1/windows.go

7
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

Loading…
Cancel
Save