Added target and terminal support.
[src/xds/xds-server.git] / lib / xdsserver / sdks.go
index b7f7e2e..4a7ba84 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 "IoT.bzh"
+ * Copyright (C) 2017-2018 "IoT.bzh"
  * Author Sebastien Douheret <sebastien@iot.bzh>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,8 +24,8 @@ import (
        "strings"
        "sync"
 
-       common "github.com/iotbzh/xds-common/golib"
-       "github.com/iotbzh/xds-server/lib/xsapiv1"
+       common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git/golib"
+       "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1"
 )
 
 // SDKs List of installed SDK
@@ -38,8 +38,8 @@ type SDKs struct {
        stop  chan struct{} // signals intentional stop
 }
 
-// NewSDKs creates a new instance of SDKs
-func NewSDKs(ctx *Context) (*SDKs, error) {
+// SDKsConstructor creates a new instance of SDKs
+func SDKsConstructor(ctx *Context) (*SDKs, error) {
        s := SDKs{
                Context:      ctx,
                Sdks:         make(map[string]*CrossSDK),
@@ -63,6 +63,12 @@ func NewSDKs(ctx *Context) (*SDKs, error) {
                return &s, err
        }
 
+       // Update SDK DB on startup by default (can be disable using config file)
+       update := true
+       if s.Config.FileConf.SdkDbUpdate != "startup" {
+               update = false
+       }
+
        s.mutex.Lock()
        defer s.mutex.Unlock()
 
@@ -73,10 +79,11 @@ func NewSDKs(ctx *Context) (*SDKs, error) {
                        continue
                }
 
-               sdksList, err := ListCrossSDK(d, s.Log)
+               sdksList, err := ListCrossSDK(d, update, s.Log)
                if err != nil {
                        // allow to use XDS even if error on list
                        s.Log.Errorf("Cannot retrieve SDK list: %v", err)
+                       sdksList, _ = ListCrossSDK(d, false, s.Log)
                }
                s.LogSillyf("'%s' SDKs list: %v", d, sdksList)
 
@@ -211,7 +218,7 @@ func (s *SDKs) monitorSDKInstallation(watchingDirs []string) {
                                sdk.Path = sdkDef.SetupFile
 
                                // Emit Folder state change event
-                               if err := s.events.Emit(xsapiv1.EVTSDKInstall, sdk, ""); err != nil {
+                               if err := s.events.Emit(xsapiv1.EVTSDKAdd, sdk, ""); err != nil {
                                        s.Log.Warningf("Cannot notify SDK install: %v", err)
                                }