chg: [filerwatcher] fix silly path bug

master v0.1.12
Jean-Louis Huynen 2021-02-19 10:19:23 +01:00
parent 7c929bd599
commit 97271a7dce
No known key found for this signature in database
GPG Key ID: 64799157F4BD6B93
1 changed files with 5 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package inputreader
import ( import (
"bytes" "bytes"
"encoding/base64" "encoding/base64"
"fmt"
"github.com/rjeczalik/notify" "github.com/rjeczalik/notify"
"io" "io"
"log" "log"
@ -13,7 +14,7 @@ import (
// and behaves like a reader // and behaves like a reader
type FileWatcherReader struct { type FileWatcherReader struct {
// Folder to watch // Folder to watch
folderfd *os.File folderstr string
// Notify Channel // Notify Channel
eic chan notify.EventInfo eic chan notify.EventInfo
// TearDown channel // TearDown channel
@ -30,9 +31,9 @@ type FileWatcherReader struct {
// NewFileWatcherReader creates a new FileWatcherReader // NewFileWatcherReader creates a new FileWatcherReader
// json specifies whether we now we handle json files // json specifies whether we now we handle json files
func NewFileWatcherReader(f *os.File, j bool) (*FileWatcherReader, error) { func NewFileWatcherReader(f string, j bool) (*FileWatcherReader, error) {
r := &FileWatcherReader{ r := &FileWatcherReader{
folderfd: f, folderstr: f,
eic: make(chan notify.EventInfo, 4096), eic: make(chan notify.EventInfo, 4096),
json: j, json: j,
watching: true, watching: true,
@ -40,7 +41,7 @@ func NewFileWatcherReader(f *os.File, j bool) (*FileWatcherReader, error) {
} }
// go routine holding the watcher // go routine holding the watcher
go func() { go func() {
if err := notify.Watch("./...", r.eic, notify.InCloseWrite); err != nil { if err := notify.Watch(fmt.Sprintf("%s/...", r.folderstr ), r.eic, notify.InCloseWrite); err != nil {
log.Fatal(err) log.Fatal(err)
} }
defer notify.Stop(r.eic) defer notify.Stop(r.eic)