@@ -490,20 +490,29 @@ func UpdateLibrariesIndex(ctx context.Context, req *rpc.UpdateLibrariesIndexRequ
490490}
491491
492492// 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 {
494494 if instances .GetInstance (req .GetInstance ().GetId ()) == nil {
495- return nil , & arduino.InvalidInstanceError {}
495+ return & arduino.InvalidInstanceError {}
496496 }
497497
498498 indexpath := configuration .DataDir (configuration .Settings )
499499
500500 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
502506 for _ , u := range urls {
503507 logrus .Info ("URL: " , u )
504508 URL , err := utils .URLParse (u )
505509 if err != nil {
506510 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
507516 continue
508517 }
509518
@@ -512,7 +521,12 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
512521 if URL .Scheme == "file" {
513522 path := paths .New (URL .Path )
514523 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
516530 }
517531
518532 fi , _ := os .Stat (path .String ())
@@ -521,6 +535,10 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
521535 TotalSize : fi .Size (),
522536 })
523537 downloadCB (& rpc.DownloadProgress {Completed : true })
538+ downloadResultCB (& rpc.DownloadResult {
539+ Url : u ,
540+ Successful : true ,
541+ })
524542 continue
525543 }
526544
@@ -532,18 +550,31 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB rp
532550 indexResource .SignatureURL .Path += ".sig"
533551 }
534552 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
536559 }
560+
561+ downloadResultCB (& rpc.DownloadResult {
562+ Url : u ,
563+ Successful : true ,
564+ })
537565 }
538566
539- return & rpc.UpdateIndexResponse {}, nil
567+ if failed {
568+ return & arduino.FailedDownloadError {Message : tr ("Some indexes could not be updated." )}
569+ }
570+ return nil
540571}
541572
542573// 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 {
545576 Instance : req .Instance ,
546- }, downloadCB )
577+ }, downloadCB , downloadResultCB )
547578 if err != nil {
548579 return err
549580 }
0 commit comments