Skip to content

Commit 06207fc

Browse files
authored
CVEDB: Fix bug in database location - use cached path intstead of default (#901)
1 parent 0a78d8b commit 06207fc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

cve_bin_tool/cvedb.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ def __init__(
6868
self.version_check = version_check
6969

7070
# set up the db if needed
71-
self.disk_location = DISK_LOCATION_DEFAULT
72-
self.dbname = os.path.join(self.disk_location, DBNAME)
71+
self.dbpath = os.path.join(self.cachedir, DBNAME)
7372
self.connection = None
7473
self.session = session
7574

@@ -241,9 +240,9 @@ def get_cvelist_if_stale(self):
241240
""" Update if the local db is more than one day old.
242241
This avoids the full slow update with every execution.
243242
"""
244-
if not os.path.isfile(self.dbname) or (
243+
if not os.path.isfile(self.dbpath) or (
245244
datetime.datetime.today()
246-
- datetime.datetime.fromtimestamp(os.path.getmtime(self.dbname))
245+
- datetime.datetime.fromtimestamp(os.path.getmtime(self.dbpath))
247246
) > datetime.timedelta(hours=24):
248247
self.refresh_cache_and_update_db()
249248
else:
@@ -577,7 +576,7 @@ def clear_cached_data(self):
577576
def db_open(self):
578577
""" Opens connection to sqlite database."""
579578
if not self.connection:
580-
self.connection = sqlite3.connect(self.dbname)
579+
self.connection = sqlite3.connect(self.dbpath)
581580

582581
def db_close(self):
583582
""" Closes connection to sqlite database."""

0 commit comments

Comments
 (0)