|
34 | 34 | from cve_bin_tool.error_handler import ERROR_CODES, CVEDBError, ErrorMode, SigningError |
35 | 35 | from cve_bin_tool.fetch_json_db import Fetch_JSON_DB |
36 | 36 | from cve_bin_tool.log import LOGGER |
37 | | -from cve_bin_tool.util import make_http_requests |
| 37 | +from cve_bin_tool.util import handle_database_lock, make_http_requests |
38 | 38 | from cve_bin_tool.version import check_latest_version |
39 | 39 |
|
40 | 40 | logging.basicConfig(level=logging.DEBUG) |
@@ -297,6 +297,7 @@ async def refresh(self) -> None: |
297 | 297 |
|
298 | 298 | await self.get_data() |
299 | 299 |
|
| 300 | + @handle_database_lock |
300 | 301 | def refresh_cache_and_update_db(self) -> None: |
301 | 302 | """Refresh cached NVD and update CVE database with latest data.""" |
302 | 303 | self.LOGGER.debug("Updating CVE data. This will take a few minutes.") |
@@ -756,6 +757,7 @@ def update_vendors(self, cve_data): |
756 | 757 |
|
757 | 758 | return updated_severity, updated_affected |
758 | 759 |
|
| 760 | + @handle_database_lock |
759 | 761 | def db_open_and_get_cursor(self) -> sqlite3.Cursor: |
760 | 762 | """Opens connection to sqlite database, returns cursor object.""" |
761 | 763 |
|
@@ -901,6 +903,7 @@ def delete_old_files_if_exists(self, path): |
901 | 903 | if (path / "metadata.json").exists(): |
902 | 904 | Path.unlink(path / "metadata.json") |
903 | 905 |
|
| 906 | + @handle_database_lock |
904 | 907 | def db_to_json(self, path, private_key, passphrase): |
905 | 908 | """Create JSON of all records in all database tables.""" |
906 | 909 | if private_key and not passphrase: |
@@ -1052,6 +1055,7 @@ def json_to_db(self, cursor, db_column, json_data): |
1052 | 1055 | elif db_column == "metrics": |
1053 | 1056 | cursor.executemany(self.INSERT_QUERIES["insert_metrics"], values) |
1054 | 1057 |
|
| 1058 | + @handle_database_lock |
1055 | 1059 | def json_to_db_wrapper(self, path, pubkey, ignore_signature, log_signature_error): |
1056 | 1060 | """Initialize the process wrapper to insert records into database from JSON.""" |
1057 | 1061 | try: |
|
0 commit comments