@@ -95,7 +95,7 @@ func Init(ctx context.Context, req *rpc.InitReq) (*rpc.InitResp, error) {
95
95
return nil , fmt .Errorf ("parsing url %s: %s" , rawurl , err )
96
96
}
97
97
}
98
- pm , lm , err := createInstance (ctx , config , req .GetLibraryManagerOnly ())
98
+ pm , lm , reqPltIndex , reqLibIndex , err := createInstance (ctx , config , req .GetLibraryManagerOnly ())
99
99
if err != nil {
100
100
return nil , fmt .Errorf ("cannot initialize package manager: %s" , err )
101
101
}
@@ -109,7 +109,9 @@ func Init(ctx context.Context, req *rpc.InitReq) (*rpc.InitResp, error) {
109
109
instances [handle ] = instance
110
110
111
111
return & rpc.InitResp {
112
- Instance : & rpc.Instance {Id : handle },
112
+ Instance : & rpc.Instance {Id : handle },
113
+ PlatformsIndexErrors : reqPltIndex ,
114
+ LibrariesIndexError : reqLibIndex ,
113
115
}, nil
114
116
}
115
117
@@ -202,17 +204,21 @@ func Rescan(ctx context.Context, req *rpc.RescanReq) (*rpc.RescanResp, error) {
202
204
return nil , fmt .Errorf ("invalid handle" )
203
205
}
204
206
205
- pm , lm , err := createInstance (ctx , coreInstance .config , coreInstance .getLibOnly )
207
+ pm , lm , reqPltIndex , reqLibIndex , err := createInstance (ctx , coreInstance .config , coreInstance .getLibOnly )
206
208
if err != nil {
207
209
return nil , fmt .Errorf ("rescanning filesystem: %s" , err )
208
210
}
209
211
coreInstance .pm = pm
210
212
coreInstance .lm = lm
211
- return & rpc.RescanResp {}, nil
213
+ return & rpc.RescanResp {
214
+ PlatformsIndexErrors : reqPltIndex ,
215
+ LibrariesIndexError : reqLibIndex ,
216
+ }, nil
212
217
}
213
218
214
- func createInstance (ctx context.Context , config * configs.Configuration , getLibOnly bool ) (* packagemanager.PackageManager , * librariesmanager.LibrariesManager , error ) {
219
+ func createInstance (ctx context.Context , config * configs.Configuration , getLibOnly bool ) (* packagemanager.PackageManager , * librariesmanager.LibrariesManager , [] string , string , error ) {
215
220
var pm * packagemanager.PackageManager
221
+ platformIndexErrors := []string {}
216
222
if ! getLibOnly {
217
223
pm = packagemanager .NewPackageManager (
218
224
config .IndexesDir (),
@@ -222,14 +228,17 @@ func createInstance(ctx context.Context, config *configs.Configuration, getLibOn
222
228
223
229
for _ , URL := range config .BoardManagerAdditionalUrls {
224
230
if err := pm .LoadPackageIndex (URL ); err != nil {
225
- return nil , nil , fmt . Errorf ( "loading " + URL . String () + " package index: %s" , err )
231
+ platformIndexErrors = append ( platformIndexErrors , err . Error () )
226
232
}
227
233
}
228
234
229
235
if err := pm .LoadHardware (config ); err != nil {
230
- return nil , nil , fmt .Errorf ("loading hardware packages: %s" , err )
236
+ return nil , nil , nil , "" , fmt .Errorf ("loading hardware packages: %s" , err )
231
237
}
232
238
}
239
+ if len (platformIndexErrors ) == 0 {
240
+ platformIndexErrors = nil
241
+ }
233
242
234
243
// Initialize library manager
235
244
// --------------------------
@@ -257,20 +266,16 @@ func createInstance(ctx context.Context, config *configs.Configuration, getLibOn
257
266
}
258
267
259
268
// Load index and auto-update it if needed
269
+ librariesIndexError := ""
260
270
if err := lm .LoadIndex (); err != nil {
261
- UpdateLibrariesIndex (ctx , lm , func (curr * rpc.DownloadProgress ) {
262
- fmt .Printf (">> %+v\n " , curr )
263
- })
264
- if err := lm .LoadIndex (); err != nil {
265
- return nil , nil , fmt .Errorf ("loading libraries index: %s" , err )
266
- }
271
+ librariesIndexError = err .Error ()
267
272
}
268
273
269
274
// Scan for libraries
270
275
if err := lm .RescanLibraries (); err != nil {
271
- return nil , nil , fmt .Errorf ("libraries rescan: %s" , err )
276
+ return nil , nil , nil , "" , fmt .Errorf ("libraries rescan: %s" , err )
272
277
}
273
- return pm , lm , nil
278
+ return pm , lm , platformIndexErrors , librariesIndexError , nil
274
279
}
275
280
276
281
func Download (d * downloader.Downloader , label string , downloadCB DownloadProgressCB ) error {
0 commit comments