From c22242e0dd0dd8b81d6e08c64b3458175d51bde8 Mon Sep 17 00:00:00 2001 From: Paul Tikken Date: Fri, 16 Feb 2024 13:39:40 +0000 Subject: [PATCH] fixes #260 --- CveXplore/VERSION | 2 +- CveXplore/core/database_maintenance/main_updater.py | 9 +++++---- CveXplore/main.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CveXplore/VERSION b/CveXplore/VERSION index 955e2d9d..53c254f4 100644 --- a/CveXplore/VERSION +++ b/CveXplore/VERSION @@ -1 +1 @@ -0.3.23 \ No newline at end of file +0.3.23.dev1 \ No newline at end of file diff --git a/CveXplore/core/database_maintenance/main_updater.py b/CveXplore/core/database_maintenance/main_updater.py index 20462ad7..999358e6 100644 --- a/CveXplore/core/database_maintenance/main_updater.py +++ b/CveXplore/core/database_maintenance/main_updater.py @@ -30,13 +30,14 @@ class MainUpdater(UpdateBaseClass): The MainUpdater class is the main class for performing database database_maintenance tasks """ - def __init__(self, datasource: DatabaseConnectionBase): + def __init__(self, datasource: DatabaseConnectionBase, datasource_type: str): """ Init a new MainUpdater class """ super().__init__(logger_name=__name__) self.datasource = datasource + self.datasource_type = datasource_type self.sources = [ {"name": "cpe", "updater": CPEDownloads}, @@ -67,7 +68,7 @@ def update(self, update_source: str | list = None): start_time = time.time() if not self.do_initialize: - if self.datasource != "api" or self.datasource != "mongodb": + if self.datasource_type != "api" and self.datasource_type != "mongodb": self.logger.info( f"Upgrading database schema to latest head, if needed..." ) @@ -128,7 +129,7 @@ def populate(self, populate_source: str | list = None): self.logger.info(f"Starting Database population....") start_time = time.time() - if self.datasource != "api" or self.datasource != "mongodb": + if self.datasource_type != "api" and self.datasource_type != "mongodb": self.logger.info(f"Upgrading database schema to latest head, if needed...") self.database_migrator.db_upgrade() @@ -190,7 +191,7 @@ def initialize(self): self.do_initialize = True - if self.datasource != "api" or self.datasource != "mongodb": + if self.datasource_type != "api" and self.datasource_type != "mongodb": self.logger.info(f"Upgrading database schema to latest head, if needed...") self.database_migrator.db_upgrade() diff --git a/CveXplore/main.py b/CveXplore/main.py index d07e288b..c96350cd 100644 --- a/CveXplore/main.py +++ b/CveXplore/main.py @@ -160,7 +160,7 @@ def __init__(self, **kwargs): database_init_parameters=self.datasource_connection_details, ).database_connection if self.datasource_type != "api": - self.database = MainUpdater(datasource=self.datasource) + self.database = MainUpdater(datasource=self.datasource, datasource_type=self.datasource_type) self._database_mapping = database_mapping