diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/update.go | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/cmd/update.go b/cmd/update.go index 86e6c7a..8615057 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -7,7 +7,6 @@ import ( "github.com/pablotron/cvez/nvdmirror" "github.com/rs/zerolog/log" "github.com/spf13/cobra" - nvd_feed "github.com/pablotron/cvez/feed" "os" "path/filepath" ) @@ -33,22 +32,16 @@ var updateCmd = &cobra.Command{ defer cache.Close() // sync data, get updates + log.Info().Msg("sync mirror") updates := nvdmirror.Sync(config, &cache, cacheDir) if len(updates) > 0 { // connect to db ctx := context.Background() db := getDb() - // build list of feeds to add + // load feeds log.Info().Msg("load feeds") - var feeds []nvd_feed.Feed - for _, row := range(updates) { - if row.Type == nvdmirror.UpdateCveYear { - feeds = append(feeds, getFeed(filepath.Join(cacheDir, row.Path))) - } - } - - if len(feeds) > 0 { + if feeds := getFeeds(cacheDir, updates); len(feeds) > 0 { log.Info().Msg("AddCveFeeds") if _, err := db.AddCveFeeds(ctx, feeds); err != nil { // FIXME: failing like this leaves an invalid cache @@ -88,6 +81,8 @@ var updateCmd = &cobra.Command{ } } } + + log.Info().Msg("done") } }, } |