From 8dc327ad1970b049589f33b0eb49a2a8510c7aab Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 18 Mar 2022 22:57:25 -0400 Subject: cmd/cmd.go: getCache(): return cache directory too --- cmd/cmd.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/cmd.go b/cmd/cmd.go index 80c1527..1619a71 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -44,24 +44,27 @@ func getDb() dbstore.DbStore { return db } -// Get cache. -func getCache() nvdmirror.JsonCache { +// Get cache and cache directory path. +func getCache() (nvdmirror.JsonCache, string) { // get path to cache directory - cacheDir, err := datadir.CacheDir() + dir, err := datadir.CacheDir() if err != nil { log.Error().Err(err).Msg("CacheDir") os.Exit(-1) } + // build cache file path + cachePath := filepath.Join(dir, "cache.json.gz") + // create cache - cache, err := nvdmirror.NewJsonCache(filepath.Join(cacheDir, "cache.json.gz")) + cache, err := nvdmirror.NewJsonCache(cachePath) if err != nil { log.Error().Err(err).Msg("NewJsonCache") os.Exit(-1) } // return cache - return cache + return cache, dir } // JSON encode data and write it to standard output -- cgit v1.2.3