@@ -490,9 +490,9 @@ 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 )
@@ -501,11 +501,18 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
501
501
if ! req .GetIgnoreCustomPackageIndexes () {
502
502
urls = append (urls , configuration .Settings .GetStringSlice ("board_manager.additional_urls" )... )
503
503
}
504
+
505
+ failed := false
504
506
for _ , u := range urls {
505
507
logrus .Info ("URL: " , u )
506
508
URL , err := utils .URLParse (u )
507
509
if err != nil {
508
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
509
516
continue
510
517
}
511
518
@@ -514,7 +521,12 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
514
521
if URL .Scheme == "file" {
515
522
path := paths .New (URL .Path )
516
523
if _ , err := packageindex .LoadIndexNoSign (path ); err != nil {
517
- 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
518
530
}
519
531
520
532
fi , _ := os .Stat (path .String ())
@@ -523,6 +535,10 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
523
535
TotalSize : fi .Size (),
524
536
})
525
537
downloadCB (& rpc.DownloadProgress {Completed : true })
538
+ downloadResultCB (& rpc.DownloadResult {
539
+ Url : u ,
540
+ Successful : true ,
541
+ })
526
542
continue
527
543
}
528
544
@@ -534,18 +550,30 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
534
550
indexResource .SignatureURL .Path += ".sig"
535
551
}
536
552
if err := indexResource .Download (indexpath , downloadCB ); err != nil {
537
- return nil , err
553
+ downloadResultCB (& rpc.DownloadResult {
554
+ Url : u ,
555
+ Error : err .Error (),
556
+ })
557
+ failed = true
538
558
}
559
+
560
+ downloadResultCB (& rpc.DownloadResult {
561
+ Url : u ,
562
+ Successful : true ,
563
+ })
539
564
}
540
565
541
- return & rpc.UpdateIndexResponse {}, nil
566
+ if failed {
567
+ return & arduino.FailedDownloadError {Message : tr ("Some indexes could not be updated." )}
568
+ }
569
+ return nil
542
570
}
543
571
544
572
// UpdateCoreLibrariesIndex updates both Cores and Libraries indexes
545
- func UpdateCoreLibrariesIndex (ctx context.Context , req * rpc.UpdateCoreLibrariesIndexRequest , downloadCB rpc.DownloadProgressCB ) error {
546
- _ , err := UpdateIndex (ctx , & rpc.UpdateIndexRequest {
573
+ func UpdateCoreLibrariesIndex (ctx context.Context , req * rpc.UpdateCoreLibrariesIndexRequest , downloadCB rpc.DownloadProgressCB , downloadResultCB rpc. DownloadResultCB ) error {
574
+ err := UpdateIndex (ctx , & rpc.UpdateIndexRequest {
547
575
Instance : req .Instance ,
548
- }, downloadCB )
576
+ }, downloadCB , downloadResultCB )
549
577
if err != nil {
550
578
return err
551
579
}
0 commit comments