X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fapiv1%2Fmake.go;h=d015d2b4b18f9f6772d11ce5df9b6350ff0e66d8;hb=330cffa06c3efea42a42ca8e908b8b24db6bba3f;hp=098e41c0ce28a5fbcfe6d24d243470ed48136c13;hpb=0805255ee01103c500f2aae8845850b3dae6a0b6;p=src%2Fxds%2Fxds-server.git diff --git a/lib/apiv1/make.go b/lib/apiv1/make.go index 098e41c..d015d2b 100644 --- a/lib/apiv1/make.go +++ b/lib/apiv1/make.go @@ -2,6 +2,7 @@ package apiv1 import ( "net/http" + "strings" "time" @@ -95,7 +96,16 @@ func (s *APIService) buildMake(c *gin.Context) { s.log.Infof("%s not emitted: WS closed - sid: %s - msg id:%d", MakeOutEvent, sid, id) return } - s.log.Debugf("%s emitted - WS sid %s - id:%d", MakeOutEvent, sid, id) + + // Retrieve project ID and RootPath + prjID := (*data)["ID"].(string) + prjRootPath := (*data)["RootPath"].(string) + + // Cleanup any references to internal rootpath in stdout & stderr + stdout = strings.Replace(stdout, prjRootPath, "", -1) + stderr = strings.Replace(stderr, prjRootPath, "", -1) + + s.log.Debugf("%s emitted - WS sid %s - id:%d - prjID:%s", MakeOutEvent, sid, id, prjID) // FIXME replace by .BroadcastTo a room err := (*so).Emit(MakeOutEvent, MakeOutMsg{ @@ -110,7 +120,7 @@ func (s *APIService) buildMake(c *gin.Context) { } // Define callback for output - eCB := func(sid string, id int, code int, err error) { + eCB := func(sid string, id int, code int, err error, data *map[string]interface{}) { s.log.Debugf("Command [Cmd ID %d] exited: code %d, error: %v", id, code, err) // IO socket can be nil when disconnected @@ -120,6 +130,14 @@ func (s *APIService) buildMake(c *gin.Context) { return } + // Retrieve project ID and RootPath + prjID := (*data)["ID"].(string) + + // XXX - workaround to be sure that Syncthing detected all changes + if err := s.mfolder.ForceSync(prjID); err != nil { + s.log.Errorf("Error while syncing folder %s: %v", prjID, err) + } + // FIXME replace by .BroadcastTo a room e := (*so).Emit(MakeExitEvent, MakeExitMsg{ CmdID: strconv.Itoa(id), @@ -148,6 +166,11 @@ func (s *APIService) buildMake(c *gin.Context) { } s.log.Debugf("Execute [Cmd ID %d]: %v", cmdID, cmd) + + data := make(map[string]interface{}) + data["ID"] = prj.ID + data["RootPath"] = prj.RootPath + err := common.ExecPipeWs(cmd, args.Env, sop, sess.ID, cmdID, execTmo, s.log, oCB, eCB, nil) if err != nil { common.APIError(c, err.Error())