30
30
package core
31
31
32
32
import (
33
- "net/url"
34
33
"os"
35
34
36
35
"github.com/bcmi-labs/arduino-cli/commands"
37
36
38
37
"github.com/bcmi-labs/arduino-cli/common"
39
38
"github.com/bcmi-labs/arduino-cli/common/formatter"
40
39
"github.com/bcmi-labs/arduino-cli/configs"
41
- "github.com/bcmi-labs/arduino-cli/task"
42
40
"github.com/sirupsen/logrus"
43
41
"github.com/spf13/cobra"
44
42
)
@@ -59,35 +57,19 @@ var updateIndexCommand = &cobra.Command{
59
57
func runUpdateIndexCommand (cmd * cobra.Command , args []string ) {
60
58
logrus .Info ("Updating package index" )
61
59
62
- downloadTasks := []task.Task {}
63
- ignoreWarns := []bool {}
64
- for _ , URL := range configs .BoardManagerAdditionalUrls {
65
- msgs := & formatter.TaskWrapperMessages {
66
- BeforeMessage : "Downloading package index from " + URL .String (),
67
- ErrorMessage : "Can't download index file, check your network connection." ,
68
- }
69
- task := formatter .WrapTask (downloadTask (URL ), msgs )
70
- downloadTasks = append (downloadTasks , task )
71
- ignoreWarns = append (ignoreWarns , false )
72
- }
73
-
74
- results := task .ExecuteSequence (downloadTasks , ignoreWarns )
75
60
failed := false
76
- for _ , result := range results {
77
- if result .Error != nil {
78
- formatter .PrintError (result .Error , "Error downloading package index" )
61
+ for _ , URL := range configs .BoardManagerAdditionalUrls {
62
+ formatter .Print ("Downloading package index from " + URL .String ())
63
+ coreIndexPath := configs .IndexPathFromURL (URL )
64
+ if err := common .DownloadIndex (coreIndexPath , URL ); err != nil {
65
+ formatter .PrintError (err , "Can't download index file." )
79
66
failed = true
80
67
}
81
68
}
69
+
82
70
if failed {
71
+ formatter .PrintErrorMessage ("Error downloading package index, check your network connection" )
83
72
os .Exit (commands .ErrNetwork )
84
73
}
85
74
formatter .Print ("Download completed." )
86
75
}
87
-
88
- func downloadTask (packageIndexURL * url.URL ) task.Task {
89
- coreIndexPath := configs .IndexPathFromURL (packageIndexURL )
90
- return func () task.Result {
91
- return task.Result {Error : common .DownloadIndex (coreIndexPath , packageIndexURL )}
92
- }
93
- }
0 commit comments