Reload indexes when restarting

This commit is contained in:
Daniel 2020-05-25 17:20:02 +02:00
parent eef8a443e4
commit 046a00f473
2 changed files with 18 additions and 11 deletions

View file

@ -194,17 +194,7 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
Beta: false,
})
err = registry.LoadIndexes()
if err != nil {
return err
}
err = registry.ScanStorage("")
if err != nil {
log.Printf("WARNING: error during storage scan: %s\n", err)
}
registry.SelectVersions()
updateRegistryIndex()
}
// logs and warning
@ -225,3 +215,17 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
return nil
}
func updateRegistryIndex() {
err := registry.LoadIndexes()
if err != nil {
log.Printf("WARNING: error loading indexes: %s\n", err)
}
err = registry.ScanStorage("")
if err != nil {
log.Printf("WARNING: error during storage scan: %s\n", err)
}
registry.SelectVersions()
}

View file

@ -191,6 +191,9 @@ func run(cmd *cobra.Command, opts *Options) (err error) {
case tryAgain && err == nil:
// upgrade
log.Println("restarting by request...")
// update index
log.Println("checking versions...")
updateRegistryIndex()
case !tryAgain && err != nil:
// fatal error
return err