]> code.ossystems Code Review - openembedded-core.git/commitdiff
cve-update-db-native: move -journal checking into do_fetch
authorChris Laplante <chris.laplante@agilent.com>
Mon, 14 Sep 2020 15:33:19 +0000 (11:33 -0400)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 14 Sep 2020 21:45:00 +0000 (22:45 +0100)
It was always questionable to do this in an anonymous function, but now
with multiconfig it is a critical mistake and leads to more strange
"Exception: sqlite3.OperationalError: disk I/O error" errors.

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/meta/cve-update-db-native.bb

index c2f713312f338246d718a666639b5c87c235c119..242fbc2f30b3296d96e856573e9f161076f514a7 100644 (file)
@@ -15,12 +15,6 @@ deltask do_populate_sysroot
 python () {
     if not bb.data.inherits_class("cve-check", d):
         raise bb.parse.SkipRecipe("Skip recipe when cve-check class is not loaded.")
-
-    if os.path.exists("%s-journal" % cve_check_db_file ):
-        os.remove("%s-journal" % cve_check_db_file)
-
-        if os.path.exists(cve_check_db_file):
-            os.remove(cve_check_db_file)
 }
 
 python do_fetch() {
@@ -41,6 +35,14 @@ python do_fetch() {
     db_dir = os.path.dirname(db_file)
     json_tmpfile = os.path.join(db_dir, 'nvd.json.gz')
 
+    if os.path.exists("{0}-journal".format(db_file)):
+        # If a journal is present the last update might have been interrupted. In that case,
+        # just wipe any leftovers and force the DB to be recreated.
+        os.remove("{0}-journal".format(db_file))
+
+        if os.path.exists(db_file):
+            os.remove(db_file)
+
     # Don't refresh the database more than once an hour
     try:
         import time