Skip to content

Commit 98e0600

Browse files
committed
avoid returning error if cannot download a tool
1 parent 4265fe0 commit 98e0600

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

tools/download.go

+19-17
Original file line numberDiff line numberDiff line change
@@ -171,22 +171,11 @@ func (t *Tools) Download(name, version, behaviour string) error {
171171
t.Logger.Println(string(body))
172172

173173
// Find the tool by name
174-
correctTool := findTool(name, version, data)
174+
correctTool, correctSystem := findTool(name, version, data)
175175

176-
if correctTool.Name == "" {
177-
return errors.New("We couldn't find a tool with the name " + name + " and version " + version)
178-
}
179-
180-
// Find the url based on system
181-
var correctSystem system
182-
max_similarity := 0.8
183-
184-
for _, s := range correctTool.Systems {
185-
similarity := smetrics.Jaro(s.Host, systems[runtime.GOOS+runtime.GOARCH])
186-
if similarity > max_similarity {
187-
correctSystem = s
188-
max_similarity = similarity
189-
}
176+
if correctTool.Name == "" || correctSystem.URL == "" {
177+
t.Logger.Println("We couldn't find a tool with the name " + name + " and version " + version)
178+
return nil
190179
}
191180

192181
key := correctTool.Name + "-" + correctTool.Version
@@ -265,7 +254,7 @@ func (t *Tools) Download(name, version, behaviour string) error {
265254
return t.writeMap()
266255
}
267256

268-
func findTool(name, version string, data index) tool {
257+
func findTool(name, version string, data index) (tool, system) {
269258
var correctTool tool
270259
correctTool.Version = "0.0"
271260

@@ -285,7 +274,20 @@ func findTool(name, version string, data index) tool {
285274
}
286275
}
287276
}
288-
return correctTool
277+
278+
// Find the url based on system
279+
var correctSystem system
280+
max_similarity := 0.8
281+
282+
for _, s := range correctTool.Systems {
283+
similarity := smetrics.Jaro(s.Host, systems[runtime.GOOS+runtime.GOARCH])
284+
if similarity > max_similarity {
285+
correctSystem = s
286+
max_similarity = similarity
287+
}
288+
}
289+
290+
return correctTool, correctSystem
289291
}
290292

291293
func stringInSlice(str string, list []string) bool {

0 commit comments

Comments
 (0)