@@ -190,26 +190,38 @@ func checkCmd(m []byte) {
190
190
go spList (false )
191
191
go spList (true )
192
192
} else if strings .HasPrefix (sl , "downloadtool" ) {
193
- args := strings .Split (s , " " )
194
- if len (args ) > 1 {
195
- go func () {
196
- var err error
197
- if args [1 ] == "avrdude" {
198
- err = Tools .Download (args [1 ], "6.0.1-arduino5" , "keep" )
199
- } else {
200
- err = Tools .Download (args [1 ], "latest" , "keep" )
201
- }
202
- if err != nil {
203
- mapD := map [string ]string {"DownloadStatus" : "Error" , "Msg" : err .Error ()}
204
- mapB , _ := json .Marshal (mapD )
205
- h .broadcastSys <- mapB
206
- } else {
207
- mapD := map [string ]string {"DownloadStatus" : "Success" , "Msg" : "Map Updated" }
208
- mapB , _ := json .Marshal (mapD )
209
- h .broadcastSys <- mapB
210
- }
211
- }()
212
- }
193
+ go func () {
194
+ args := strings .Split (s , " " )
195
+ var tool , toolVersion , behaviour string
196
+ toolVersion = "latest"
197
+ behaviour = "keep"
198
+ if len (args ) <= 1 {
199
+ mapD := map [string ]string {"DownloadStatus" : "Error" , "Msg" : "Not enough arguments" }
200
+ mapB , _ := json .Marshal (mapD )
201
+ h .broadcastSys <- mapB
202
+ return
203
+ }
204
+ if len (args ) > 1 {
205
+ tool = args [1 ]
206
+ }
207
+ if len (args ) > 2 {
208
+ toolVersion = args [2 ]
209
+ }
210
+ if len (args ) > 3 {
211
+ behaviour = args [3 ]
212
+ }
213
+
214
+ err := Tools .Download (tool , toolVersion , behaviour )
215
+ if err != nil {
216
+ mapD := map [string ]string {"DownloadStatus" : "Error" , "Msg" : err .Error ()}
217
+ mapB , _ := json .Marshal (mapD )
218
+ h .broadcastSys <- mapB
219
+ } else {
220
+ mapD := map [string ]string {"DownloadStatus" : "Success" , "Msg" : "Map Updated" }
221
+ mapB , _ := json .Marshal (mapD )
222
+ h .broadcastSys <- mapB
223
+ }
224
+ }()
213
225
} else if strings .HasPrefix (sl , "bufferalgorithm" ) {
214
226
go spBufferAlgorithms ()
215
227
} else if strings .HasPrefix (sl , "log" ) {
0 commit comments