From a8a4cee66732e97b9d428f2fb8a54853e6d40950 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 2 May 2018 17:13:35 +0800 Subject: [PATCH] =?UTF-8?q?gfsnotify=E4=BF=AE=E5=A4=8D=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E6=96=87=E4=BB=B6=E7=9A=84=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98=EF=BC=8C=E5=B9=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=EF=BC=8C=E5=AE=8C?= =?UTF-8?q?=E6=88=90Windows=5Fx386=E7=B3=BB=E7=BB=9F=E4=B8=8B=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g/os/gfsnotify/gfsnotify.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/g/os/gfsnotify/gfsnotify.go b/g/os/gfsnotify/gfsnotify.go index 00bb189cd..2b50f1d7c 100644 --- a/g/os/gfsnotify/gfsnotify.go +++ b/g/os/gfsnotify/gfsnotify.go @@ -10,6 +10,7 @@ package gfsnotify import ( "errors" + "gitee.com/johng/gf/g/os/glog" "github.com/fsnotify/fsnotify" "gitee.com/johng/gf/g/os/gfile" "gitee.com/johng/gf/g/os/gcache" @@ -94,7 +95,9 @@ func (w *Watcher) Close() { // 添加对指定文件/目录的监听,并给定回调函数 func (w *Watcher) Add(path string, callback func(event *Event)) error { - if !gfile.Exists(path) { + // 这里统一转换为当前系统的绝对路径,便于统一监控文件名称 + path = gfile.RealPath(path) + if path == "" { return errors.New(path + " does not exist") } // 注册回调函数 @@ -138,9 +141,8 @@ func (w *Watcher) startWatchLoop() { Op : Op(ev.Op), }) - //case err := <- w.watcher.Errors: - // log.Println("error : ", err); - // return + case err := <- w.watcher.Errors: + glog.Error("error : ", err); } } }()