]> go.fuhry.dev Git - fsnotify.git/commitdiff
Fixes issue #70
authorChris Howey <chris@howey.me>
Sat, 19 Oct 2013 15:48:14 +0000 (10:48 -0500)
committerChris Howey <chris@howey.me>
Sat, 19 Oct 2013 15:48:14 +0000 (10:48 -0500)
Not exactly the best fix, but it'll do.

fsnotify_bsd.go

index 5d909e5378c88b74a48f07d78833b2eb9a46012d..9f7dbbf2653a91c001d09c5e59605c08354102ec 100644 (file)
@@ -349,7 +349,7 @@ func (w *Watcher) readEvents() {
                        fileEvent.Name = w.paths[int(watchEvent.Ident)]
                        fileInfo := w.finfo[int(watchEvent.Ident)]
                        w.pmut.Unlock()
-                       if fileInfo.IsDir() && !fileEvent.IsDelete() {
+                       if fileInfo != nil && fileInfo.IsDir() && !fileEvent.IsDelete() {
                                // Double check to make sure the directory exist. This can happen when
                                // we do a rm -fr on a recursively watched folders and we receive a
                                // modification event first but the folder has been deleted and later
@@ -360,7 +360,7 @@ func (w *Watcher) readEvents() {
                                }
                        }
 
-                       if fileInfo.IsDir() && fileEvent.IsModify() && !fileEvent.IsDelete() {
+                       if fileInfo != nil && fileInfo.IsDir() && fileEvent.IsModify() && !fileEvent.IsDelete() {
                                w.sendDirectoryChangeEvents(fileEvent.Name)
                        } else {
                                // Send the event on the events channel