@@ -17,7 +17,6 @@ package tools
17
17
18
18
import (
19
19
"context"
20
- "encoding/json"
21
20
"errors"
22
21
"os"
23
22
"os/exec"
36
35
Arch = runtime .GOARCH
37
36
)
38
37
39
- func pathExists (path string ) bool {
40
- _ , err := os .Stat (path )
41
- if err == nil {
42
- return true
43
- }
44
- if os .IsNotExist (err ) {
45
- return false
46
- }
47
- return true
48
- }
49
-
50
38
// Download will parse the index at the indexURL for the tool to download.
51
39
// It will extract it in a folder in .arduino-create, and it will update the
52
40
// Installed map.
@@ -62,44 +50,17 @@ func pathExists(path string) bool {
62
50
// If version is not "latest" and behaviour is "replace", it will download the
63
51
// version again. If instead behaviour is "keep" it will not download the version
64
52
// if it already exists.
53
+ //
54
+ // At the moment the value of behaviour is ignored.
65
55
func (t * Tools ) Download (pack , name , version , behaviour string ) error {
66
56
67
- body , err := t .index .Read ()
68
- if err != nil {
69
- return err
70
- }
71
-
72
- var data pkgs.Index
73
- json .Unmarshal (body , & data )
74
-
75
- // Find the tool by name
76
- correctTool , correctSystem := findTool (pack , name , version , data )
77
-
78
- if correctTool .Name == "" || correctSystem .URL == "" {
79
- t .logger ("We couldn't find a tool with the name " + name + " and version " + version + " packaged by " + pack )
80
- return nil
81
- }
82
-
83
- key := correctTool .Name + "-" + correctTool .Version
84
-
85
- // Check if it already exists
86
- if behaviour == "keep" {
87
- location , ok := t .getMapValue (key )
88
- if ok && pathExists (location ) {
89
- // overwrite the default tool with this one
90
- t .setMapValue (correctTool .Name , location )
91
- t .logger ("The tool is already present on the system" )
92
- return t .writeMap ()
93
- }
94
- }
95
-
96
57
tool := pkgs .New (t .index , t .directory .String ())
97
- _ , err = tool .Install (context .Background (), & tools.ToolPayload {Name : correctTool . Name , Version : correctTool . Version , Packager : pack })
58
+ _ , err : = tool .Install (context .Background (), & tools.ToolPayload {Name : name , Version : version , Packager : pack })
98
59
if err != nil {
99
60
return err
100
61
}
101
62
102
- path := filepath .Join (pack , correctTool . Name , correctTool . Version )
63
+ path := filepath .Join (pack , name , version )
103
64
safePath , err := utilities .SafeJoin (t .directory .String (), path )
104
65
if err != nil {
105
66
return err
0 commit comments