Skip to content

Commit

Permalink
Check for valid package_index when updating core index files
Browse files Browse the repository at this point in the history
Fix #81
  • Loading branch information
cmaglie committed Nov 8, 2018
1 parent 9fb116c commit 5a02ce4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions commands/core/update_index.go
Expand Up @@ -25,6 +25,7 @@ import (

"go.bug.st/downloader"

"github.com/arduino/arduino-cli/arduino/cores/packageindex"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/configs"
Expand Down Expand Up @@ -84,6 +85,11 @@ func updateIndex(URL *url.URL) {
os.Exit(commands.ErrNetwork)
}

if _, err := packageindex.LoadIndex(tmp); err != nil {
formatter.PrintError(err, "Invalid package index in "+URL.String())
os.Exit(commands.ErrGeneric)
}

if err := indexDirPath.MkdirAll(); err != nil {
formatter.PrintError(err, "Can't create data directory "+indexDirPath.String())
os.Exit(commands.ErrGeneric)
Expand Down

0 comments on commit 5a02ce4

Please sign in to comment.