aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-03-18 22:57:25 -0400
committerPaul Duncan <pabs@pablotron.org>2022-03-18 22:57:25 -0400
commit8dc327ad1970b049589f33b0eb49a2a8510c7aab (patch)
tree7d3e37a0567008f9dc9d741efd808fbf5932a663 /cmd
parentf857551bc4405abe5d41e44d63cc77270ef92ab5 (diff)
downloadcvez-8dc327ad1970b049589f33b0eb49a2a8510c7aab.tar.bz2
cvez-8dc327ad1970b049589f33b0eb49a2a8510c7aab.zip
cmd/cmd.go: getCache(): return cache directory too
Diffstat (limited to 'cmd')
-rw-r--r--cmd/cmd.go13
1 files changed, 8 insertions, 5 deletions
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