|
16 | 16 | package instance
|
17 | 17 |
|
18 | 18 | import (
|
19 |
| - "context" |
20 |
| - |
21 | 19 | "github.com/arduino/arduino-cli/commands"
|
22 |
| - "github.com/arduino/arduino-cli/configuration" |
23 | 20 | "github.com/arduino/arduino-cli/i18n"
|
24 | 21 | "github.com/arduino/arduino-cli/internal/cli/feedback"
|
25 | 22 | rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
|
@@ -71,12 +68,6 @@ func Init(instance *rpc.Instance) {
|
71 | 68 | // In case of loading failures return a list of errors for each platform or library that we failed to load.
|
72 | 69 | // Required Package and library indexes files are automatically downloaded.
|
73 | 70 | func InitWithProfile(instance *rpc.Instance, profileName string, sketchPath *paths.Path) *rpc.Profile {
|
74 |
| - // In case the CLI is executed for the first time |
75 |
| - if err := FirstUpdate(instance); err != nil { |
76 |
| - feedback.Warning(tr("Error initializing instance: %v", err)) |
77 |
| - return nil |
78 |
| - } |
79 |
| - |
80 | 71 | downloadCallback := feedback.ProgressBar()
|
81 | 72 | taskCallback := feedback.TaskProgress()
|
82 | 73 |
|
@@ -110,70 +101,3 @@ func InitWithProfile(instance *rpc.Instance, profileName string, sketchPath *pat
|
110 | 101 |
|
111 | 102 | return profile
|
112 | 103 | }
|
113 |
| - |
114 |
| -// FirstUpdate downloads libraries and packages indexes if they don't exist. |
115 |
| -// This ideally is only executed the first time the CLI is run. |
116 |
| -func FirstUpdate(instance *rpc.Instance) error { |
117 |
| - // Gets the data directory to verify if library_index.json and package_index.json exist |
118 |
| - dataDir := configuration.DataDir(configuration.Settings) |
119 |
| - |
120 |
| - libraryIndex := dataDir.Join("library_index.json") |
121 |
| - packageIndex := dataDir.Join("package_index.json") |
122 |
| - |
123 |
| - if libraryIndex.Exist() && packageIndex.Exist() { |
124 |
| - return nil |
125 |
| - } |
126 |
| - |
127 |
| - // The library_index.json file doesn't exists, that means the CLI is run for the first time |
128 |
| - // so we proceed with the first update that downloads the file |
129 |
| - if libraryIndex.NotExist() { |
130 |
| - err := commands.UpdateLibrariesIndex(context.Background(), |
131 |
| - &rpc.UpdateLibrariesIndexRequest{ |
132 |
| - Instance: instance, |
133 |
| - }, |
134 |
| - feedback.ProgressBar(), |
135 |
| - ) |
136 |
| - if err != nil { |
137 |
| - return err |
138 |
| - } |
139 |
| - } |
140 |
| - |
141 |
| - // The package_index.json file doesn't exists, that means the CLI is run for the first time, |
142 |
| - // similarly to the library update we download that file and all the other package indexes |
143 |
| - // from additional_urls |
144 |
| - if packageIndex.NotExist() { |
145 |
| - err := commands.UpdateIndex(context.Background(), |
146 |
| - &rpc.UpdateIndexRequest{ |
147 |
| - Instance: instance, |
148 |
| - IgnoreCustomPackageIndexes: true, |
149 |
| - }, |
150 |
| - feedback.ProgressBar()) |
151 |
| - if err != nil { |
152 |
| - return err |
153 |
| - } |
154 |
| - } |
155 |
| - |
156 |
| - return nil |
157 |
| -} |
158 |
| - |
159 |
| -// CreateInstanceAndRunFirstUpdate creates an instance and runs `FirstUpdate`. |
160 |
| -// It is mandatory for all `update-index` commands to call this |
161 |
| -func CreateInstanceAndRunFirstUpdate() *rpc.Instance { |
162 |
| - // We don't initialize any CoreInstance when updating indexes since we don't need to. |
163 |
| - // Also meaningless errors might be returned when calling this command with --additional-urls |
164 |
| - // since the CLI would be searching for a corresponding file for the additional urls set |
165 |
| - // as argument but none would be obviously found. |
166 |
| - inst, status := Create() |
167 |
| - if status != nil { |
168 |
| - feedback.Fatal(tr("Error creating instance: %v", status), feedback.ErrGeneric) |
169 |
| - } |
170 |
| - |
171 |
| - // In case this is the first time the CLI is run we need to update indexes |
172 |
| - // to make it work correctly, we must do this explicitly in this command since |
173 |
| - // we must use instance.Create instead of instance.CreateAndInit for the |
174 |
| - // reason stated above. |
175 |
| - if err := FirstUpdate(inst); err != nil { |
176 |
| - feedback.Fatal(tr("Error updating indexes: %v", err), feedback.ErrGeneric) |
177 |
| - } |
178 |
| - return inst |
179 |
| -} |
0 commit comments