File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 2
2
package main
3
3
4
4
import (
5
+ "encoding/json"
5
6
"errors"
6
7
log "github.com/Sirupsen/logrus"
7
8
"io"
@@ -92,13 +93,30 @@ func spDownloadTool(name string, url string) {
92
93
fileName , err := downloadFromUrl (url + "/" + name + "-" + runtime .GOOS + "-" + runtime .GOARCH + ".zip" )
93
94
if err != nil {
94
95
log .Error ("Could not download flashing tools!" )
96
+ mapD := map [string ]string {"DownloadStatus" : "Error" , "Msg" : err .Error ()}
97
+ mapB , _ := json .Marshal (mapD )
98
+ h .broadcastSys <- mapB
99
+ return
100
+ }
101
+ err = Unzip (fileName , tempToolsPath )
102
+ if err != nil {
103
+ log .Error ("Could not unzip flashing tools!" )
104
+ mapD := map [string ]string {"DownloadStatus" : "Error" , "Msg" : err .Error ()}
105
+ mapB , _ := json .Marshal (mapD )
106
+ h .broadcastSys <- mapB
95
107
return
96
108
}
97
- Unzip (fileName , tempToolsPath )
98
109
} else {
99
110
log .Info ("Tool already present, skipping download" )
100
111
}
101
112
102
113
// will be something like ${tempfolder}/avrdude/bin/avrdude
103
114
globalToolsMap ["{runtime.tools." + name + ".path}" ] = tempToolsPath + "/" + name
115
+
116
+ log .Info ("Map Updated" )
117
+ mapD := map [string ]string {"DownloadStatus" : "Success" , "Msg" : "Map Updated" }
118
+ mapB , _ := json .Marshal (mapD )
119
+ h .broadcastSys <- mapB
120
+ return
121
+
104
122
}
You can’t perform that action at this time.
0 commit comments