@@ -490,20 +490,29 @@ func UpdateLibrariesIndex(ctx context.Context, req *rpc.UpdateLibrariesIndexRequ
490
490
}
491
491
492
492
// UpdateIndex FIXMEDOC
493
- func UpdateIndex (ctx context.Context , req * rpc.UpdateIndexRequest , downloadCB rpc.DownloadProgressCB ) ( * rpc.UpdateIndexResponse , error ) {
493
+ func UpdateIndex (ctx context.Context , req * rpc.UpdateIndexRequest , downloadCB rpc.DownloadProgressCB , downloadResultCB rpc.DownloadResultCB ) error {
494
494
if instances .GetInstance (req .GetInstance ().GetId ()) == nil {
495
- return nil , & arduino.InvalidInstanceError {}
495
+ return & arduino.InvalidInstanceError {}
496
496
}
497
497
498
498
indexpath := configuration .DataDir (configuration .Settings )
499
499
500
500
urls := []string {globals .DefaultIndexURL }
501
- urls = append (urls , configuration .Settings .GetStringSlice ("board_manager.additional_urls" )... )
501
+ if ! req .GetIgnoreCustomPackageIndexes () {
502
+ urls = append (urls , configuration .Settings .GetStringSlice ("board_manager.additional_urls" )... )
503
+ }
504
+
505
+ failed := false
502
506
for _ , u := range urls {
503
507
logrus .Info ("URL: " , u )
504
508
URL , err := utils .URLParse (u )
505
509
if err != nil {
506
510
logrus .Warnf ("unable to parse additional URL: %s" , u )
511
+ downloadResultCB (& rpc.DownloadResult {
512
+ Url : u ,
513
+ Error : fmt .Sprintf ("%s: %v" , tr ("Unable to parse URL" ), err ),
514
+ })
515
+ failed = true
507
516
continue
508
517
}
509
518
@@ -512,7 +521,12 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
512
521
if URL .Scheme == "file" {
513
522
path := paths .New (URL .Path )
514
523
if _ , err := packageindex .LoadIndexNoSign (path ); err != nil {
515
- return nil , & arduino.InvalidArgumentError {Message : tr ("Invalid package index in %s" , path ), Cause : err }
524
+ downloadResultCB (& rpc.DownloadResult {
525
+ Url : u ,
526
+ Error : fmt .Sprintf ("%s: %v" , tr ("Invalid package index in %s" , path ), err ),
527
+ })
528
+ failed = true
529
+ continue
516
530
}
517
531
518
532
fi , _ := os .Stat (path .String ())
@@ -521,6 +535,10 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
521
535
TotalSize : fi .Size (),
522
536
})
523
537
downloadCB (& rpc.DownloadProgress {Completed : true })
538
+ downloadResultCB (& rpc.DownloadResult {
539
+ Url : u ,
540
+ Successful : true ,
541
+ })
524
542
continue
525
543
}
526
544
@@ -532,18 +550,31 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
532
550
indexResource .SignatureURL .Path += ".sig"
533
551
}
534
552
if err := indexResource .Download (indexpath , downloadCB ); err != nil {
535
- return nil , err
553
+ downloadResultCB (& rpc.DownloadResult {
554
+ Url : u ,
555
+ Error : err .Error (),
556
+ })
557
+ failed = true
558
+ continue
536
559
}
560
+
561
+ downloadResultCB (& rpc.DownloadResult {
562
+ Url : u ,
563
+ Successful : true ,
564
+ })
537
565
}
538
566
539
- return & rpc.UpdateIndexResponse {}, nil
567
+ if failed {
568
+ return & arduino.FailedDownloadError {Message : tr ("Some indexes could not be updated." )}
569
+ }
570
+ return nil
540
571
}
541
572
542
573
// UpdateCoreLibrariesIndex updates both Cores and Libraries indexes
543
- func UpdateCoreLibrariesIndex (ctx context.Context , req * rpc.UpdateCoreLibrariesIndexRequest , downloadCB rpc.DownloadProgressCB ) error {
544
- _ , err := UpdateIndex (ctx , & rpc.UpdateIndexRequest {
574
+ func UpdateCoreLibrariesIndex (ctx context.Context , req * rpc.UpdateCoreLibrariesIndexRequest , downloadCB rpc.DownloadProgressCB , downloadResultCB rpc. DownloadResultCB ) error {
575
+ err := UpdateIndex (ctx , & rpc.UpdateIndexRequest {
545
576
Instance : req .Instance ,
546
- }, downloadCB )
577
+ }, downloadCB , downloadResultCB )
547
578
if err != nil {
548
579
return err
549
580
}
0 commit comments