Skip to content

Commit 7fc92e4

Browse files
committed
Update variable names to pass checks + simplify code
1 parent a7e099e commit 7fc92e4

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

commands/instances.go

+15-21
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,23 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
201201
}
202202

203203
indexpath := paths.New(configuration.Settings.GetString("directories.Data"))
204-
json_paths := []string{}
205-
json_paths = append(json_paths, configuration.Settings.GetStringSlice("board_manager.additional_paths")...)
206204

207-
for _, x := range json_paths {
208-
logrus.Info("JSON_PATH: ", x)
205+
for _, x := range configuration.Settings.GetStringSlice("board_manager.additional_paths") {
206+
logrus.Info("JSON PATH: ", x)
209207

210-
path_to_json, _ := paths.New(x).Abs()
208+
pathJSON, _ := paths.New(x).Abs()
211209

212-
if _, err := packageindex.LoadIndexNoSign(path_to_json); err != nil {
213-
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})
210+
if _, err := packageindex.LoadIndexNoSign(pathJSON); err != nil {
211+
return nil, fmt.Errorf("invalid package index in %s: %s", pathJSON, err)
221212
}
222213

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+
223221
}
224222

225223
urls := []string{globals.DefaultIndexURL}
@@ -672,14 +670,10 @@ func createInstance(ctx context.Context, getLibOnly bool) (*createInstanceResult
672670
}
673671
}
674672

675-
//indexpath := paths.New(configuration.Settings.GetString("directories.Data"))
676-
json_paths := []string{}
677-
json_paths = append(json_paths, configuration.Settings.GetStringSlice("board_manager.additional_paths")...)
678-
for _, x := range json_paths {
679-
//path_to_json, err := paths.New(x).Abs()
680-
path_to_json, _ := paths.New(x).Abs()
673+
for _, x := range configuration.Settings.GetStringSlice("board_manager.additional_paths") {
674+
pathJSON, _ := paths.New(x).Abs()
681675

682-
_, err := res.Pm.LoadPackageIndexFromFile(path_to_json)
676+
_, err := res.Pm.LoadPackageIndexFromFile(pathJSON)
683677
if err != nil {
684678
res.PlatformIndexErrors = append(res.PlatformIndexErrors, err.Error())
685679
}

0 commit comments

Comments
 (0)