Skip to content

Commit 88e3771

Browse files
committed
Added gRPC flag to ignore Cloud API detection in BoardList* operations
1 parent 3802b09 commit 88e3771

File tree

4 files changed

+113
-77
lines changed

4 files changed

+113
-77
lines changed

commands/service_board_list.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func identifyViaCloudAPI(props *properties.Map, settings *configuration.Settings
139139
}
140140

141141
// identify returns a list of boards checking first the installed platforms or the Cloud API
142-
func identify(pme *packagemanager.Explorer, port *discovery.Port, settings *configuration.Settings) ([]*rpc.BoardListItem, error) {
142+
func identify(pme *packagemanager.Explorer, port *discovery.Port, settings *configuration.Settings, skipCloudAPI bool) ([]*rpc.BoardListItem, error) {
143143
boards := []*rpc.BoardListItem{}
144144
if port.Properties == nil {
145145
return boards, nil
@@ -170,7 +170,7 @@ func identify(pme *packagemanager.Explorer, port *discovery.Port, settings *conf
170170

171171
// if installed cores didn't recognize the board, try querying
172172
// the builder API if the board is a USB device port
173-
if len(boards) == 0 {
173+
if len(boards) == 0 && !skipCloudAPI {
174174
items, err := identifyViaCloudAPI(port.Properties, settings)
175175
if err != nil {
176176
// this is bad, but keep going
@@ -225,7 +225,7 @@ func (s *arduinoCoreServerImpl) BoardList(ctx context.Context, req *rpc.BoardLis
225225

226226
ports := []*rpc.DetectedPort{}
227227
for _, port := range dm.List() {
228-
boards, err := identify(pme, port, s.settings)
228+
boards, err := identify(pme, port, s.settings, req.GetSkipCloudApiForBoardDetection())
229229
if err != nil {
230230
warnings = append(warnings, err.Error())
231231
}
@@ -298,7 +298,7 @@ func (s *arduinoCoreServerImpl) BoardListWatch(req *rpc.BoardListWatchRequest, s
298298

299299
boardsError := ""
300300
if event.Type == "add" {
301-
boards, err := identify(pme, event.Port, s.settings)
301+
boards, err := identify(pme, event.Port, s.settings, req.GetSkipCloudApiForBoardDetection())
302302
if err != nil {
303303
boardsError = err.Error()
304304
}

commands/service_board_list_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func TestBoardIdentifySorting(t *testing.T) {
157157
defer release()
158158

159159
settings := configuration.NewSettings()
160-
res, err := identify(pme, &discovery.Port{Properties: idPrefs}, settings)
160+
res, err := identify(pme, &discovery.Port{Properties: idPrefs}, settings, true)
161161
require.NoError(t, err)
162162
require.NotNil(t, res)
163163
require.Len(t, res, 4)

0 commit comments

Comments
 (0)