Merge pull request #80 from safing/fix/pmctl-download

Fix downloading of assets in pmctl
This commit is contained in:
Daniel 2020-06-20 16:27:05 +02:00 committed by GitHub
commit dc35964d8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 16 deletions

View file

@ -35,7 +35,7 @@ var (
}, },
Beta: false, Beta: false,
DevMode: false, DevMode: false,
Online: false, Online: true, // is disabled later based on command
} }
rootCmd = &cobra.Command{ rootCmd = &cobra.Command{
@ -182,17 +182,12 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
Beta: false, Beta: false,
}) })
registry.AddIndex(updater.Index{ // TODO: enable loading beta versions
Path: "beta.json", // registry.AddIndex(updater.Index{
Stable: false, // Path: "beta.json",
Beta: true, // Stable: false,
}) // Beta: true,
// })
registry.AddIndex(updater.Index{
Path: "all/intel/intel.json",
Stable: true,
Beta: false,
})
updateRegistryIndex() updateRegistryIndex()
} }

View file

@ -104,12 +104,10 @@ func handleRun(cmd *cobra.Command, opts *Options) (err error) {
return return
} }
func run(cmd *cobra.Command, opts *Options) (err error) { func run(cmd *cobra.Command, opts *Options) (err error) { //nolint:gocognit
// set download option // set download option
if opts.AllowDownload { registry.Online = opts.AllowDownload
registry.Online = true
}
// parse identifier // parse identifier
opts.ShortIdentifier = path.Dir(opts.Identifier) opts.ShortIdentifier = path.Dir(opts.Identifier)
@ -187,8 +185,16 @@ func run(cmd *cobra.Command, opts *Options) (err error) {
log.Println("error seems to be permanent, giving up...") log.Println("error seems to be permanent, giving up...")
return err return err
} }
// resilience
time.Sleep(time.Duration(tries) * 2 * time.Second)
if tries >= 2 {
// try updating
updateRegistryIndex()
}
log.Println("trying again...") log.Println("trying again...")
case tryAgain && err == nil: case tryAgain && err == nil:
// reset error count
tries = 0
// upgrade // upgrade
log.Println("restarting by request...") log.Println("restarting by request...")
// update index // update index