@@ -202,24 +202,6 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
202202
203203 indexpath := paths .New (configuration .Settings .GetString ("directories.Data" ))
204204
205- for _ , x := range configuration .Settings .GetStringSlice ("board_manager.additional_paths" ) {
206- logrus .Info ("JSON PATH: " , x )
207-
208- pathJSON , _ := paths .New (x ).Abs ()
209-
210- if _ , err := packageindex .LoadIndexNoSign (pathJSON ); err != nil {
211- return nil , fmt .Errorf ("invalid package index in %s: %s" , pathJSON , err )
212- }
213-
214- fi , _ := os .Stat (x )
215- downloadCB (& rpc.DownloadProgress {
216- File : "Updating index: " + pathJSON .Base (),
217- TotalSize : fi .Size (),
218- })
219- downloadCB (& rpc.DownloadProgress {Completed : true })
220-
221- }
222-
223205 urls := []string {globals .DefaultIndexURL }
224206 urls = append (urls , configuration .Settings .GetStringSlice ("board_manager.additional_urls" )... )
225207 for _ , u := range urls {
@@ -230,6 +212,26 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
230212 continue
231213 }
232214
215+ if URL .Scheme == "file" {
216+ path := paths .New (URL .Path )
217+ pathJSON , err := path .Abs ()
218+ if err != nil {
219+ return nil , fmt .Errorf ("can't get absolute path of %v: %w" , path , err )
220+ }
221+
222+ if _ , err := packageindex .LoadIndexNoSign (pathJSON ); err != nil {
223+ return nil , fmt .Errorf ("invalid package index in %s: %s" , pathJSON , err )
224+ }
225+
226+ fi , _ := os .Stat (URL .Path )
227+ downloadCB (& rpc.DownloadProgress {
228+ File : "Updating index: " + pathJSON .Base (),
229+ TotalSize : fi .Size (),
230+ })
231+ downloadCB (& rpc.DownloadProgress {Completed : true })
232+ continue
233+ }
234+
233235 logrus .WithField ("url" , URL ).Print ("Updating index" )
234236
235237 var tmp * paths.Path
@@ -665,16 +667,21 @@ func createInstance(ctx context.Context, getLibOnly bool) (*createInstanceResult
665667 continue
666668 }
667669
668- if err := res .Pm .LoadPackageIndex (URL ); err != nil {
669- res .PlatformIndexErrors = append (res .PlatformIndexErrors , err .Error ())
670- }
671- }
670+ if URL .Scheme == "file" {
671+ path := paths .New (URL .Path )
672+ pathJSON , err := path .Abs ()
673+ if err != nil {
674+ return nil , fmt .Errorf ("can't get absolute path of %v: %w" , path , err )
675+ }
672676
673- for _ , x := range configuration .Settings .GetStringSlice ("board_manager.additional_paths" ) {
674- pathJSON , _ := paths .New (x ).Abs ()
677+ _ , err = res .Pm .LoadPackageIndexFromFile (pathJSON )
678+ if err != nil {
679+ res .PlatformIndexErrors = append (res .PlatformIndexErrors , err .Error ())
680+ }
681+ continue
682+ }
675683
676- _ , err := res .Pm .LoadPackageIndexFromFile (pathJSON )
677- if err != nil {
684+ if err := res .Pm .LoadPackageIndex (URL ); err != nil {
678685 res .PlatformIndexErrors = append (res .PlatformIndexErrors , err .Error ())
679686 }
680687 }
0 commit comments