Skip to content

Commit 372288d

Browse files
committed
Use absolute file path to package_index.json
1 parent 474bdf9 commit 372288d

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

arduino/cores/packageindex/index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func LoadIndex(jsonIndexFile *paths.Path) (*Index, error) {
314314
}
315315

316316
// LoadIndex reads a package_index.json from a file and returns the corresponding Index structure.
317-
func LoadIndexNoSign(jsonIndexFile *paths.Path, valid_signature bool) (*Index, error) {
317+
func LoadIndexNoSign(jsonIndexFile *paths.Path) (*Index, error) {
318318
buff, err := jsonIndexFile.ReadFile()
319319
if err != nil {
320320
return nil, err

commands/instances.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)