backend: Don't watch symlinks nor temporary directories
This commit is contained in:
parent
b8f573ce86
commit
191c89f7ad
@ -30,7 +30,7 @@ func watchsubdir(watcher *fsnotify.Watcher, pathname string) error {
|
|||||||
} else {
|
} else {
|
||||||
for _, d := range ds {
|
for _, d := range ds {
|
||||||
p := path.Join(pathname, d.Name())
|
p := path.Join(pathname, d.Name())
|
||||||
if d.IsDir() && d.Name() != ".tmp" {
|
if d.IsDir() && d.Name() != ".tmp" && d.Mode() & os.ModeSymlink == 0 {
|
||||||
if err := watchsubdir(watcher, p); err != nil {
|
if err := watchsubdir(watcher, p); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -113,12 +113,12 @@ func main() {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case ev := <-watcher.Events:
|
case ev := <-watcher.Events:
|
||||||
if d, err := os.Stat(ev.Name); err == nil && d.IsDir() && ev.Op & fsnotify.Create == fsnotify.Create {
|
if d, err := os.Lstat(ev.Name); err == nil && ev.Op & fsnotify.Create == fsnotify.Create && d.Mode().IsDir() && d.Mode() & os.ModeSymlink == 0 && d.Name() != ".tmp" {
|
||||||
// Register new subdirectory
|
// Register new subdirectory
|
||||||
if err := watchsubdir(watcher, ev.Name); err != nil {
|
if err := watchsubdir(watcher, ev.Name); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
} else if ev.Op & watchedNotify == watchedNotify {
|
} else if ev.Op & watchedNotify == watchedNotify && d.Mode().IsRegular() {
|
||||||
if *debugINotify {
|
if *debugINotify {
|
||||||
log.Println("Treating event:", ev, "for", ev.Name)
|
log.Println("Treating event:", ev, "for", ev.Name)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user