From 82a96af793f3d2ba190b658d7586e44d3854ba82 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sat, 19 Mar 2022 23:38:19 -0400 Subject: cmd/update.go: use getFeeds() --- cmd/update.go | 15 +++++---------- 1 file 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") } }, } -- cgit v1.2.3