Remove pointer from fsnotify.Event
This commit is contained in:
parent
8b4773e24e
commit
abb1479f04
|
@ -77,7 +77,7 @@ func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, fi os.FileInfo) *FileCh
|
||||||
for {
|
for {
|
||||||
prevSize := fw.Size
|
prevSize := fw.Size
|
||||||
|
|
||||||
var evt *fsnotify.Event
|
var evt fsnotify.Event
|
||||||
var ok bool
|
var ok bool
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
type InotifyTracker struct {
|
type InotifyTracker struct {
|
||||||
mux sync.Mutex
|
mux sync.Mutex
|
||||||
watcher *fsnotify.Watcher
|
watcher *fsnotify.Watcher
|
||||||
chans map[string]chan *fsnotify.Event
|
chans map[string]chan fsnotify.Event
|
||||||
done map[string]chan bool
|
done map[string]chan bool
|
||||||
watch chan *watchInfo
|
watch chan *watchInfo
|
||||||
remove chan string
|
remove chan string
|
||||||
|
@ -36,7 +36,7 @@ var (
|
||||||
goRun = func() {
|
goRun = func() {
|
||||||
shared = &InotifyTracker{
|
shared = &InotifyTracker{
|
||||||
mux: sync.Mutex{},
|
mux: sync.Mutex{},
|
||||||
chans: make(map[string]chan *fsnotify.Event),
|
chans: make(map[string]chan fsnotify.Event),
|
||||||
done: make(map[string]chan bool),
|
done: make(map[string]chan bool),
|
||||||
watch: make(chan *watchInfo),
|
watch: make(chan *watchInfo),
|
||||||
remove: make(chan string),
|
remove: make(chan string),
|
||||||
|
@ -78,7 +78,7 @@ func RemoveWatch(fname string) {
|
||||||
// Events returns a channel to which FileEvents corresponding to the input filename
|
// Events returns a channel to which FileEvents corresponding to the input filename
|
||||||
// will be sent. This channel will be closed when removeWatch is called on this
|
// will be sent. This channel will be closed when removeWatch is called on this
|
||||||
// filename.
|
// filename.
|
||||||
func Events(fname string) chan *fsnotify.Event {
|
func Events(fname string) chan fsnotify.Event {
|
||||||
shared.mux.Lock()
|
shared.mux.Lock()
|
||||||
defer shared.mux.Unlock()
|
defer shared.mux.Unlock()
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ func (shared *InotifyTracker) addWatch(fname string) error {
|
||||||
defer shared.mux.Unlock()
|
defer shared.mux.Unlock()
|
||||||
|
|
||||||
if shared.chans[fname] == nil {
|
if shared.chans[fname] == nil {
|
||||||
shared.chans[fname] = make(chan *fsnotify.Event)
|
shared.chans[fname] = make(chan fsnotify.Event)
|
||||||
shared.done[fname] = make(chan bool)
|
shared.done[fname] = make(chan bool)
|
||||||
}
|
}
|
||||||
return shared.watcher.Add(fname)
|
return shared.watcher.Add(fname)
|
||||||
|
@ -118,7 +118,7 @@ func (shared *InotifyTracker) removeWatch(fname string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sendEvent sends the input event to the appropriate Tail.
|
// sendEvent sends the input event to the appropriate Tail.
|
||||||
func (shared *InotifyTracker) sendEvent(event *fsnotify.Event) {
|
func (shared *InotifyTracker) sendEvent(event fsnotify.Event) {
|
||||||
shared.mux.Lock()
|
shared.mux.Lock()
|
||||||
ch := shared.chans[event.Name]
|
ch := shared.chans[event.Name]
|
||||||
done := shared.done[event.Name]
|
done := shared.done[event.Name]
|
||||||
|
@ -153,7 +153,7 @@ func (shared *InotifyTracker) run() {
|
||||||
if !open {
|
if !open {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
shared.sendEvent(&event)
|
shared.sendEvent(event)
|
||||||
|
|
||||||
case err, open := <-shared.watcher.Errors:
|
case err, open := <-shared.watcher.Errors:
|
||||||
if !open {
|
if !open {
|
||||||
|
|
Loading…
Reference in New Issue