File tree 2 files changed +15
-3
lines changed 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,19 @@ import (
23
23
log "github.com/sirupsen/logrus"
24
24
)
25
25
26
+ // getDataDir returns the full path to the default Arduino Create Agent data directory.
27
+ func getDataDir () * paths.Path {
28
+ userDir , err := os .UserHomeDir ()
29
+ if err != nil {
30
+ log .Panicf ("Could not get user dir: %s" , err )
31
+ }
32
+ dataDir := paths .New (userDir , ".arduino-create" )
33
+ if err := dataDir .MkdirAll (); err != nil {
34
+ log .Panicf ("Could not create data dir: %s" , err )
35
+ }
36
+ return dataDir
37
+ }
38
+
26
39
// getDefaultConfigDir returns the full path to the default Arduino Create Agent configuration directory.
27
40
func getDefaultConfigDir () * paths.Path {
28
41
// UserConfigDir returns the default root directory to use
Original file line number Diff line number Diff line change @@ -192,11 +192,10 @@ func loop() {
192
192
src , _ := os .Executable ()
193
193
srcPath := paths .New (src ) // The path of the agent's binary
194
194
srcDir := srcPath .Parent () // The directory of the agent's binary
195
- agentDir := getDefaultConfigDir ()
196
195
197
196
// Instantiate Tools
198
197
Tools = tools.Tools {
199
- Directory : agentDir .String (),
198
+ Directory : getDataDir () .String (),
200
199
IndexURL : * indexURL ,
201
200
Logger : func (msg string ) {
202
201
mapD := map [string ]string {"DownloadStatus" : "Pending" , "Msg" : msg }
@@ -407,7 +406,7 @@ func loop() {
407
406
r .POST ("/update" , updateHandler )
408
407
409
408
// Mount goa handlers
410
- goa := v2 .Server (agentDir .String ())
409
+ goa := v2 .Server (getDataDir () .String ())
411
410
r .Any ("/v2/*path" , gin .WrapH (goa ))
412
411
413
412
go func () {
You can’t perform that action at this time.
0 commit comments