watcher do not watch CHMOD
authorjaehoon.hyun <jaehoon.hyun@samsung.com>
Tue, 2 Apr 2019 06:25:44 +0000 (15:25 +0900)
committerjaehoon.hyun <jaehoon.hyun@samsung.com>
Tue, 2 Apr 2019 06:25:44 +0000 (15:25 +0900)
src/configuremgr/watchConfPath.go

index 9828707..fcf5703 100644 (file)
@@ -3,6 +3,7 @@ package configuremgr
 import (
 
   "strings"
+  "os"
   
   confdescription "configuremgr/description"
 
@@ -47,11 +48,19 @@ func (cfgMgr *ConfigureMgr) installConfigure(path string) {
   cfg := new(confdescription.Doc)
 
   libPath, confPath := cfgMgr.getdirname(path)
+
+  //NOTE : copy but really copy, it can be not existed.
+  for {
+    if _, err := os.Stat(confPath); os.IsNotExist(err) {
+
+    }else{
+      break
+    }
+  }
   sconf.Must(cfg).Read(ini.File(confPath))
   cfgMgr.IScoringMgr.PushLibPath(libPath, cfg, cfgMgr.IScoringMgr.Ch)
   cfgMgr.IDiscoveryMgr.PushConfPath(cfg)
   // cfgMgr.IAppExecuteMgr.PushConfPath(cfg)
-
 }
 
 func (cfgMgr *ConfigureMgr) getdirname(path string) (libPath, confPath string) {
@@ -91,25 +100,29 @@ func (cfgMgr *ConfigureMgr) Watch(path string) {
           }
 
           ILog.Println("log event:", event)
-          if event.Op & fsnotify.Create == fsnotify.Create {
-            cfgMgr.installConfigure(event.Name)
+          switch(event.Op){
+            case fsnotify.Create:
+            // case fsnotify.Chmod:
+              cfgMgr.installConfigure(event.Name)
+
           }
+          
       case err, ok := <-watcher.Errors:
           if !ok {
               return
           }
           ELog.Println("error:", err)
-      }
-  }
+
+      } //selecte end
+    } //for end
   }()
 
   err = watcher.Add(path)
   if err != nil {
     ELog.Fatal(err)
   }
-
   
-  <- cfgMgr.Done 
+  <- cfgMgr.Done
   ILog.Println("configuremgr watch end")
 
 }
\ No newline at end of file