Merge pull request #56 from safing/feature/reload-indexes-when-restarting

Reload indexes when restarting
This commit is contained in:
Patrick Pacher 2020-05-26 10:43:16 +02:00 committed by GitHub
commit 1ae770cb23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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