Check the mtime of the database before updating, and if it's less than 24 hours ago don't refresh. This saves the HTTP fetches to determine if the data has been updated.
Signed-off-by: Ross Burton <[email protected]> --- meta/recipes-core/meta/cve-update-db-native.bb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb index cabbde5066c..2afca94fc6b 100644 --- a/meta/recipes-core/meta/cve-update-db-native.bb +++ b/meta/recipes-core/meta/cve-update-db-native.bb @@ -22,7 +22,7 @@ python do_populate_cve_db() { Update NVD database with json data feed """ - import sqlite3, urllib, shutil, gzip, re + import sqlite3, urllib, shutil, gzip, re, time from datetime import date BASE_URL = "https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-" @@ -37,6 +37,11 @@ python do_populate_cve_db() { if not os.path.isdir(db_dir): os.mkdir(db_dir) + expiry = time.time() - (60*60*24) # This time yesterday + if os.path.exists(db_file) and expiry < os.path.getmtime(db_file): + bb.note("CVE data updated less than 24 hours ago, not refreshing. Delete %s to force update." % db_file) + return + # Connect to database conn = sqlite3.connect(db_file) c = conn.cursor() -- 2.20.1 -- _______________________________________________ Openembedded-core mailing list [email protected] http://lists.openembedded.org/mailman/listinfo/openembedded-core
