@@ -21,6 +21,7 @@ import (
2121 "fmt"
2222 "io/ioutil"
2323 "net/url"
24+ "os"
2425 "path"
2526
2627 "github.com/arduino/arduino-cli/arduino/builder"
@@ -202,16 +203,25 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
202203 indexpath := paths .New (configuration .Settings .GetString ("directories.Data" ))
203204 json_paths := []string {}
204205 json_paths = append (json_paths , configuration .Settings .GetStringSlice ("board_manager.additional_paths" )... )
206+
205207 for _ , x := range json_paths {
206208 logrus .Info ("JSON_PATH: " , x )
207- //path_to_json, err := paths.New(x).Abs()
208- path_to_json := indexpath .Join (x )
209209
210- if _ , err := packageindex .LoadIndexNoSign (path_to_json , false ); err != nil {
210+ path_to_json , _ := paths .New (x ).Abs ()
211+
212+ if _ , err := packageindex .LoadIndexNoSign (path_to_json ); err != nil {
211213 return nil , fmt .Errorf ("invalid package index in %s: %s" , path_to_json , err )
214+ } else {
215+ fi , _ := os .Stat (x )
216+ downloadCB (& rpc.DownloadProgress {
217+ File : "Updating index: " + path_to_json .Base (),
218+ TotalSize : fi .Size (),
219+ })
220+ downloadCB (& rpc.DownloadProgress {Completed : true })
212221 }
213222
214223 }
224+
215225 urls := []string {globals .DefaultIndexURL }
216226 urls = append (urls , configuration .Settings .GetStringSlice ("board_manager.additional_urls" )... )
217227 for _ , u := range urls {
@@ -662,12 +672,12 @@ func createInstance(ctx context.Context, getLibOnly bool) (*createInstanceResult
662672 }
663673 }
664674
665- indexpath := paths .New (configuration .Settings .GetString ("directories.Data" ))
675+ // indexpath := paths.New(configuration.Settings.GetString("directories.Data"))
666676 json_paths := []string {}
667677 json_paths = append (json_paths , configuration .Settings .GetStringSlice ("board_manager.additional_paths" )... )
668678 for _ , x := range json_paths {
669679 //path_to_json, err := paths.New(x).Abs()
670- path_to_json := indexpath . Join ( x )
680+ path_to_json , _ := paths . New ( x ). Abs ( )
671681
672682 _ , err := res .Pm .LoadPackageIndexFromFile (path_to_json )
673683 if err != nil {
0 commit comments